-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.fsx
91 lines (70 loc) · 2.19 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
#r "paket: groupref build //"
#load "./.fake/build.fsx/intellisense.fsx"
#r "netstandard"
open System.IO
open Fake.Core
open Fake.DotNet
open Fake.IO
Target.initEnvironment ()
let libPath = "./src"
let testsPath = "./test"
let npm args workingDir =
let npmPath =
match ProcessUtils.tryFindFileOnPath "npm" with
| Some path -> path
| None ->
"npm was not found in path. Please install it and make sure it's available from your path. " +
"See https://safe-stack.github.io/docs/quickstart/#install-pre-requisites for more info"
|> failwith
let arguments = args |> String.split ' ' |> Arguments.OfArgs
RawCommand (npmPath, arguments)
|> CreateProcess.fromCommand
|> CreateProcess.withWorkingDirectory workingDir
|> CreateProcess.ensureExitCode
|> Proc.run
|> ignore
let dotnet cmd workingDir =
let result = DotNet.exec (DotNet.Options.withWorkingDirectory workingDir) cmd ""
if result.ExitCode <> 0 then failwithf "'dotnet %s' failed in %s" cmd workingDir
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
let cleanDirs dirs = dirs |> List.iter Shell.cleanDir
Target.create "Clean" <| fun _ ->
[ Path.Combine(testsPath, "bin")
Path.Combine(testsPath, "obj")
Path.Combine(libPath, "bin")
Path.Combine(libPath, "obj") ]
|> cleanDirs
cleanBundles()
Target.create "InstallNpmPackages" <| fun _ -> npm "install" "."
Target.create "Live" <| fun _ ->
npm "start" "."
Target.create "RunTests" <| fun _ ->
printfn "Building %s with Fable" testsPath
npm "test" "."
npm "run headless-tests" "."
cleanBundles()
cleanDirs [ "dist" ]
Target.create "Package" <| fun _ ->
dotnet "build -c Release" libPath
open Fake.Core.TargetOperators
"Clean"
==> "InstallNpmPackages"
==> "Live"
"Clean"
==> "InstallNpmPackages"
==> "RunTests"
"Clean"
==> "InstallNpmPackages"
==> "RunTests"
==> "Package"
Target.runOrDefaultWithArguments "RunTests"