@@ -52,12 +52,18 @@ module Util =
5252 let runNpx command args =
5353 run ( " npx " + command + " " + ( String.concat " " args))
5454
55+ let runNpmScript script args =
56+ run ( " npm run " + script + " -- " + ( String.concat " " args))
57+
5558 let runNpmScriptAsync script args =
5659 runAsync ( " npm run " + script + " -- " + ( String.concat " " args))
5760
5861 let runFable projectDir =
5962 runFableWithArgs projectDir []
6063
64+ let runMocha testDir =
65+ runNpmScript " mocha" [ $" {testDir} -r esm --reporter dot -t 10000" ]
66+
6167 let resolveDir dir =
6268 __ SOURCE_ DIRECTORY__ </> dir
6369
@@ -180,7 +186,7 @@ let testJsFast() =
180186 let testProj = " tests/Main/Fable.Tests.fsproj"
181187 let buildDir = " build/tests-js"
182188 run $" node --eval \" require('esm')(module)('{fableJs}')\" {fableJs} {testProj} {buildDir}"
183- run $ " npx mocha { buildDir} -r esm --reporter dot -t 10000 "
189+ runMocha buildDir
184190
185191
186192let buildStandalone ( opts : {| minify: bool ; watch: bool |}) =
@@ -230,19 +236,19 @@ let buildStandalone (opts: {| minify: bool; watch: bool |}) =
230236 ]
231237
232238 // make standalone bundle dist
233- runNpx " rollup" rollupArgs
239+ runNpmScript " rollup" rollupArgs
234240 if opts.minify then
235- runNpx " terser" [
241+ runNpmScript " terser" [
236242 buildDir </> " bundle.js"
237243 " -o " + distDir </> " bundle.min.js"
238244 " --mangle"
239245 " --compress"
240246 ]
241247
242248 // make standalone worker dist
243- runNpx " rollup" [ $" {buildDir}/worker/Worker.js -o {buildDir}/worker.js --format iife" ]
249+ runNpmScript " rollup" [ $" {buildDir}/worker/Worker.js -o {buildDir}/worker.js --format iife" ]
244250 // runNpx "webpack" [sprintf "--entry ./%s/worker.js --output ./%s/worker.min.js --config ./%s/../worker.config.js" buildDir distDir projectDir]
245- runNpx " terser" [ $" {buildDir}/worker.js -o {distDir}/worker.min.js --mangle --compress" ]
251+ runNpmScript " terser" [ $" {buildDir}/worker.js -o {distDir}/worker.min.js --mangle --compress" ]
246252
247253 // print bundle size
248254 fileSizeInBytes ( distDir </> " bundle.min.js" ) / 1000. |> printfn " Bundle size: %f KB"
@@ -312,8 +318,8 @@ let testJs(minify) =
312318 runInDir fableDir " npm link ../fable-standalone"
313319
314320 // Test fable-compiler-js locally
315- run ( " node " + fableDir + " tests/Main/Fable.Tests.fsproj " + buildDir)
316- run ( " npx mocha " + buildDir + " -r esm --reporter dot -t 10000 " )
321+ run $ " node { fableDir} tests/Main/Fable.Tests.fsproj { buildDir} "
322+ runMocha buildDir
317323
318324 // // Another local fable-compiler-js test
319325 // runInDir (fableDir </> "test") "node .. test_script.fsx"
@@ -342,7 +348,7 @@ let test() =
342348 " --exclude Fable.Core"
343349 ]
344350
345- run $ " npx mocha { buildDir} -r esm --reporter dot -t 10000 "
351+ runMocha buildDir
346352
347353 runInDir projectDir " dotnet run"
348354
0 commit comments