Skip to content

Commit 4c6c93a

Browse files
committed
chore: fix ./build.sh quicktest typescript to run only (don't start a watch mode)
1 parent 8e1c2b8 commit 4c6c93a

File tree

2 files changed

+64
-38
lines changed

2 files changed

+64
-38
lines changed

src/Fable.Build/Quicktest/Core.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ open Build.Utils
88
type RunMode =
99
| RunScript
1010
| RunCommand of string
11+
| NoRun
1112

1213
type QuicktestConfig =
1314
{
@@ -32,6 +33,7 @@ let genericQuicktest (config: QuicktestConfig) (args: string list) =
3233
// Use appendRaw to avoid quoting the command
3334
|> CmdLine.appendRaw "--run"
3435
|> CmdLine.appendRaw command
36+
| NoRun -> cmdLine
3537

3638
let projectDir = Path.Resolve config.ProjectDir
3739

src/Fable.Build/Quicktest/TypeScript.fs

Lines changed: 62 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ open Build.FableLibrary
44
open Build.Quicktest.Core
55
open BlackFox.CommandLine
66
open Build.Utils
7+
open SimpleExec
78
open System.IO
89

910
let 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

Comments
 (0)