-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Maxime Mangel
committed
Sep 18, 2023
1 parent
ac1a4c8
commit 19773b5
Showing
10 changed files
with
215 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
module Build.Quicktest.Core | ||
|
||
open Build.FableLibrary | ||
open SimpleExec | ||
open BlackFox.CommandLine | ||
open Build.Utils | ||
|
||
type RunMode = | ||
| RunScript | ||
| RunCommand of string | ||
|
||
type QuicktestConfig = { | ||
Language: string | ||
FableLibBuilder: BuildFableLibrary | ||
ProjectDir: string | ||
Extension: string | ||
RunMode: RunMode | ||
} | ||
|
||
let genericQuicktest (config: QuicktestConfig) (args: string list) = | ||
let skipFableLibrary = args |> List.contains "--fast" | ||
|
||
config.FableLibBuilder.Run(skipFableLibrary) | ||
|
||
let appendRunMode (cmdLine: CmdLine) = | ||
match config.RunMode with | ||
| RunScript -> cmdLine |> CmdLine.appendRaw "--runScript" | ||
| RunCommand command -> | ||
cmdLine | ||
// Use appendRaw to avoid quoting the command | ||
|> CmdLine.appendRaw "--run" | ||
|> CmdLine.appendRaw command | ||
|
||
let projectDir = Path.Resolve config.ProjectDir | ||
|
||
Command.Fable( | ||
CmdLine.empty | ||
|> CmdLine.appendRaw "clean" | ||
|
||
|> CmdLine.appendRaw projectDir | ||
|> CmdLine.appendPrefix "--lang" config.Language | ||
|> CmdLine.appendPrefix "--extension" config.Extension | ||
|> CmdLine.appendRaw "--yes" | ||
, workingDirectory = projectDir | ||
) | ||
|
||
Command.WatchFableAsync( | ||
CmdLine.empty | ||
|> CmdLine.appendRaw projectDir | ||
|> CmdLine.appendPrefix "--lang" config.Language | ||
|> CmdLine.appendPrefix "--extension" config.Extension | ||
|> CmdLine.appendPrefix "--exclude" "Fable.Core" | ||
|> CmdLine.appendRaw "--noCache" | ||
|> CmdLine.appendRaw "--watch" | ||
|> appendRunMode, | ||
workingDirectory = projectDir | ||
) | ||
|> Async.AwaitTask | ||
|> Async.RunSynchronously |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Build.Quicktest.Dart | ||
|
||
open Build.FableLibrary | ||
open Build.Quicktest.Core | ||
|
||
let handle (args: string list) = | ||
genericQuicktest | ||
{ | ||
Language = "dart" | ||
FableLibBuilder = BuildFableLibraryDart() | ||
ProjectDir = "src/quicktest-dart" | ||
Extension = ".dart" | ||
RunMode = RunScript | ||
} | ||
args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Build.Quicktest.JavaScript | ||
|
||
open Build.FableLibrary | ||
open BlackFox.CommandLine | ||
open Build.Utils | ||
open SimpleExec | ||
open Build.Quicktest.Core | ||
|
||
let handle (args: string list) = | ||
genericQuicktest | ||
{ | ||
Language = "javascript" | ||
FableLibBuilder = BuildFableLibraryJavaScript() | ||
ProjectDir = "src/quicktest" | ||
Extension = ".js" | ||
RunMode = RunScript | ||
} | ||
args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Build.Quicktest.Python | ||
|
||
open Build.FableLibrary | ||
open Build.Quicktest.Core | ||
|
||
|
||
|
||
let handle (args: string list) = | ||
genericQuicktest | ||
{ | ||
Language = "python" | ||
FableLibBuilder = BuildFableLibraryPython() | ||
ProjectDir = "src/quicktest-py" | ||
Extension = ".py" | ||
RunMode = RunScript | ||
} | ||
args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Build.Quicktest.Rust | ||
|
||
open Build.FableLibrary | ||
open Build.Quicktest.Core | ||
|
||
let handle (args: string list) = | ||
genericQuicktest | ||
{ | ||
Language = "rust" | ||
FableLibBuilder = BuildFableLibraryRust() | ||
ProjectDir = "src/quicktest-rust" | ||
Extension = ".rs" | ||
RunMode = RunScript | ||
} | ||
args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
module Build.Quicktest.TypeScript | ||
|
||
open Build.FableLibrary | ||
open Build.Quicktest.Core | ||
open BlackFox.CommandLine | ||
open Build.Utils | ||
open System.IO | ||
|
||
let handle (args: string list) = | ||
|
||
let srcDir = Path.Resolve "src/quicktest" | ||
let outDir = Path.Resolve "build/quicktest-ts" | ||
let mainFile = outDir </> "Quicktest.fs.js" | ||
|
||
// Make sure the output directory exists, so nodemon doesn't complain | ||
FileInfo(mainFile).Create() |> ignore | ||
|
||
let tscCommand = | ||
CmdLine.empty | ||
|> CmdLine.appendRaw "npx" | ||
|> CmdLine.appendRaw "tsc" | ||
|> CmdLine.appendRaw "-w" | ||
|> CmdLine.appendPrefix "-p" srcDir | ||
|> CmdLine.appendPrefix "--outDir" outDir | ||
|> CmdLine.toString | ||
|
||
let nodemonCommand = | ||
CmdLine.empty | ||
|> CmdLine.appendRaw "npx" | ||
|> CmdLine.appendRaw "nodemon" | ||
|> CmdLine.appendPrefix "--delay" "500ms" | ||
|> CmdLine.appendPrefix "-w" outDir | ||
|> CmdLine.appendRaw mainFile | ||
|> CmdLine.toString | ||
|
||
let appendQuotedCommand (arg: string) (cmd: CmdLine) = | ||
cmd | ||
|> CmdLine.appendRaw "\"" | ||
|> CmdLine.appendRaw arg | ||
|> CmdLine.appendRaw "\"" | ||
|
||
let runCommand = | ||
CmdLine.empty | ||
|> CmdLine.appendRaw "npx" | ||
|> CmdLine.appendRaw "concurrently" | ||
|> appendQuotedCommand tscCommand | ||
|> appendQuotedCommand nodemonCommand | ||
|> CmdLine.toString | ||
|
||
genericQuicktest | ||
{ | ||
Language = "typescript" | ||
FableLibBuilder = BuildFableLibraryTypeScript() | ||
ProjectDir = "src/quicktest" | ||
Extension = ".fs.ts" | ||
RunMode = RunCommand runCommand | ||
} | ||
args |