@@ -4,9 +4,11 @@ open Build.FableLibrary
44open Build.Quicktest .Core
55open BlackFox.CommandLine
66open Build.Utils
7+ open SimpleExec
78open System.IO
89
910let handle ( args : string list ) =
11+ let isWatch = args |> List.contains " --watch"
1012
1113 let srcDir = Path.Resolve " src/quicktest"
1214 let outDir = Path.Resolve " temp/quicktest-ts"
@@ -17,41 +19,63 @@ let handle (args: string list) =
1719 // Make sure to dispose the file handle, to avoid file locking
1820 FileInfo( mainFile) .Create() |> _. Dispose()
1921
20- let tscCommand =
21- CmdLine.empty
22- |> CmdLine.appendRaw " npx"
23- |> CmdLine.appendRaw " tsc"
24- |> CmdLine.appendRaw " -w"
25- |> CmdLine.appendPrefix " -p" srcDir
26- |> CmdLine.appendPrefix " --outDir" outDir
27- |> CmdLine.toString
28-
29- let nodemonCommand =
30- CmdLine.empty
31- |> CmdLine.appendRaw " npx"
32- |> CmdLine.appendRaw " nodemon"
33- |> CmdLine.appendPrefix " --delay" " 500ms"
34- |> CmdLine.appendPrefix " -w" outDir
35- |> CmdLine.appendRaw mainFile
36- |> CmdLine.toString
37-
38- let appendQuotedCommand ( arg : string ) ( cmd : CmdLine ) =
39- cmd |> CmdLine.appendRaw " \" " |> CmdLine.appendRaw arg |> CmdLine.appendRaw " \" "
40-
41- let runCommand =
42- CmdLine.empty
43- |> CmdLine.appendRaw " npx"
44- |> CmdLine.appendRaw " concurrently"
45- |> appendQuotedCommand tscCommand
46- |> appendQuotedCommand nodemonCommand
47- |> CmdLine.toString
48-
49- genericQuicktest
50- {
51- Language = " typescript"
52- FableLibBuilder = BuildFableLibraryTypeScript()
53- ProjectDir = " src/quicktest"
54- Extension = " .fs.ts"
55- RunMode = RunCommand runCommand
56- }
57- args
22+ if isWatch then
23+ let tscCommand =
24+ CmdLine.empty
25+ |> CmdLine.appendRaw " npx"
26+ |> CmdLine.appendRaw " tsc"
27+ |> CmdLine.appendRaw " -w"
28+ |> CmdLine.appendPrefix " -p" srcDir
29+ |> CmdLine.appendPrefix " --outDir" outDir
30+ |> CmdLine.toString
31+
32+ let nodemonCommand =
33+ CmdLine.empty
34+ |> CmdLine.appendRaw " npx"
35+ |> CmdLine.appendRaw " nodemon"
36+ |> CmdLine.appendPrefix " --delay" " 500ms"
37+ |> CmdLine.appendPrefix " -w" outDir
38+ |> CmdLine.appendRaw mainFile
39+ |> CmdLine.toString
40+
41+ let appendQuotedCommand ( arg : string ) ( cmd : CmdLine ) =
42+ cmd |> CmdLine.appendRaw " \" " |> CmdLine.appendRaw arg |> CmdLine.appendRaw " \" "
43+
44+ let watchCommand =
45+ CmdLine.empty
46+ |> CmdLine.appendRaw " npx"
47+ |> CmdLine.appendRaw " concurrently"
48+ |> appendQuotedCommand tscCommand
49+ |> appendQuotedCommand nodemonCommand
50+ |> CmdLine.toString
51+
52+ genericQuicktest
53+ {
54+ Language = " typescript"
55+ FableLibBuilder = BuildFableLibraryTypeScript()
56+ ProjectDir = " src/quicktest"
57+ Extension = " .fs.ts"
58+ RunMode = RunCommand watchCommand
59+ }
60+ args
61+ else
62+ // Non-watch: run Fable, then tsc, then node as separate sequential steps
63+ genericQuicktest
64+ {
65+ Language = " typescript"
66+ FableLibBuilder = BuildFableLibraryTypeScript()
67+ ProjectDir = " src/quicktest"
68+ Extension = " .fs.ts"
69+ RunMode = NoRun
70+ }
71+ args
72+
73+ let tscArgs =
74+ CmdLine.empty
75+ |> CmdLine.appendRaw " tsc"
76+ |> CmdLine.appendPrefix " -p" srcDir
77+ |> CmdLine.appendPrefix " --outDir" outDir
78+ |> CmdLine.toString
79+
80+ Command.Run( " npx" , tscArgs)
81+ Command.Run( " node" , mainFile)
0 commit comments