forked from fable-compiler/Fable
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTypeScript.fs
More file actions
85 lines (68 loc) · 2.86 KB
/
Copy pathTypeScript.fs
File metadata and controls
85 lines (68 loc) · 2.86 KB
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
module Build.Test.TypeScript
open Build.FableLibrary
open System.IO
open Build.Utils
open BlackFox.CommandLine
open SimpleExec
open Fake.IO
let private projectDir = Path.Resolve("tests", "TypeScript")
let private fableDest = Path.Resolve("temp", "tests", "TypeScript")
let private tscDest = Path.Resolve("temp", "tests", "TypeScriptCompiled")
let handle (args: string list) =
let forceFableLibrary = args |> List.contains "--force-fable-library"
let isWatch = args |> List.contains "--watch"
let noDotnet = args |> List.contains "--no-dotnet"
BuildFableLibraryTypeScript().Run(forceFableLibrary)
Directory.clean fableDest
Directory.clean tscDest
Shell.copyFile fableDest (projectDir </> "tsconfig.json")
let tscArgs = $"tsc --outDir {tscDest}"
let testArgs =
"--test-reporter spec --test-timeout 20000 --test temp/tests/TypeScript/Main.js"
let fableArgs =
CmdLine.concat
[
CmdLine.empty
|> CmdLine.appendRaw projectDir
|> CmdLine.appendPrefix "--outDir" fableDest
|> CmdLine.appendPrefix "--lang" "typescript"
|> CmdLine.appendPrefix "--exclude" "Fable.Core"
// |> CmdLine.appendPrefix "--typedArrays" "false"
|> CmdLine.appendRaw "--noCache"
// Let Fable handle the TypeScript invocation
if isWatch then
CmdLine.empty
|> CmdLine.appendRaw "--watch"
|> CmdLine.appendRaw "--runWatch"
|> CmdLine.appendRaw $"npx {tscArgs}"
]
let nodemonArgs =
CmdLine.empty
|> CmdLine.appendRaw "nodemon"
|> CmdLine.appendPrefix "-e" "js"
|> CmdLine.appendPrefix "--watch" tscDest
// Avoid polluting the logs when a lot of files change at once
|> CmdLine.appendPrefix "--delay" "1s"
|> CmdLine.appendRaw "--exec"
|> CmdLine.appendRaw "\"node"
|> CmdLine.appendRaw testArgs
|> CmdLine.appendRaw "\""
|> CmdLine.toString
if isWatch then
Async.Parallel
[
if not noDotnet then
Command.RunAsync("dotnet", "watch test -c Release", workingDirectory = projectDir)
|> Async.AwaitTask
Command.WatchFableAsync(fableArgs, workingDirectory = fableDest)
|> Async.AwaitTask
Command.RunAsync("npx", nodemonArgs, workingDirectory = tscDest)
|> Async.AwaitTask
]
|> Async.RunSynchronously
|> ignore
else
Command.Run("dotnet", "test -c Release", workingDirectory = projectDir)
Command.Fable(fableArgs, workingDirectory = fableDest)
Command.Run("npx", tscArgs, workingDirectory = fableDest)
Command.Run("node", testArgs, workingDirectory = tscDest)