forked from Zaid-Ajaj/Fable.SimpleJson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
104 lines (84 loc) · 2.7 KB
/
build.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#r @"packages/build/FAKE/tools/FakeLib.dll"
open System
open System.IO
open Fake
let libPath = "./src"
let testsPath = "./test"
let platformTool tool winTool =
let tool = if isUnix then tool else winTool
tool
|> ProcessHelper.tryFindFileOnPath
|> function Some t -> t | _ -> failwithf "%s not found" tool
let nodeTool = platformTool "node" "node.exe"
let mutable dotnetCli = "dotnet"
let run fileName args workingDir =
printfn "CWD: %s" workingDir
let fileName, args =
if isUnix
then fileName, args else "cmd", ("/C " + fileName + " " + args)
let ok =
execProcess (fun info ->
info.FileName <- fileName
info.WorkingDirectory <- workingDir
info.Arguments <- args) TimeSpan.MaxValue
if not ok then failwith (sprintf "'%s> %s %s' task failed" workingDir fileName args)
let delete file =
if File.Exists(file)
then File.Delete file
else ()
let cleanBundles() =
Path.Combine("public", "bundle.js")
|> Path.GetFullPath
|> delete
Path.Combine("public", "bundle.js.map")
|> Path.GetFullPath
|> delete
Target "Clean" <| fun _ ->
[ testsPath </> "bin"
testsPath </> "obj"
libPath </> "bin"
libPath </> "obj" ]
|> CleanDirs
cleanBundles()
Target "InstallNpmPackages" (fun _ ->
printfn "Node version:"
run "node" "--version" __SOURCE_DIRECTORY__
run "npm" "install" __SOURCE_DIRECTORY__
)
Target "RunLiveTests" <| fun _ ->
run "npm" "run start" testsPath
let publish projectPath = fun () ->
[ projectPath </> "bin"
projectPath </> "obj" ] |> CleanDirs
run dotnetCli "restore --no-cache" projectPath
run dotnetCli "pack -c Release" projectPath
let nugetKey =
match environVarOrNone "NUGET_KEY" with
| Some nugetKey -> nugetKey
| None -> failwith "The Nuget API key must be set in a NUGET_KEY environmental variable"
let nupkg =
Directory.GetFiles(projectPath </> "bin" </> "Release")
|> Seq.head
|> Path.GetFullPath
let pushCmd = sprintf "nuget push %s -s nuget.org -k %s" nupkg nugetKey
run dotnetCli pushCmd projectPath
Target "PublishNuget" (publish libPath)
Target "CompileFableTestProject" <| fun _ ->
run "npm" "run build" testsPath
Target "RunTests" <| fun _ ->
printfn "Building %s with Fable" testsPath
run "npm" "test" "."
run "npm" "run headless-tests" "."
CleanDirs [ "dist" ]
cleanBundles()
run "npm" "run test-nagareyama" "."
run "npm" "run headless-nagareyama-tests" "."
cleanBundles()
CleanDirs [ "dist" ]
"Clean"
==> "InstallNpmPackages"
==> "RunLiveTests"
"Clean"
==> "InstallNpmPackages"
==> "RunTests"
RunTargetOrDefault "RunTests"