Skip to content

Commit

Permalink
fix(CLI): Run invocation on Windows
Browse files Browse the repository at this point in the history
Addresses:

> ERROR: Unknown option "--args,-e"

Reported in #781.
  • Loading branch information
thewtex committed May 5, 2023
1 parent 33abb6b commit 21f6b9a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/itk-wasm-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function test(options) {
}
if(process.platform === "win32"){
var dockerBuild = spawnSync('"C:\\Program Files\\Git\\bin\\sh.exe"',
["--login", "-i", "-c", `"${buildDir}/itk-wasm-build-env ctest --test-dir ${ctestTestDir} ` + ctestArgs + '"'], {
["--login", "-i", "-c", `"${buildDir}/itk-wasm-build-env ctest --test-dir ${ctestTestDir} ` + ctestArgs.join(' ') + '"'], {
env: process.env,
stdio: 'inherit',
shell: true
Expand Down Expand Up @@ -194,26 +194,27 @@ function run(wasmBinary, options) {
wasmRuntime = options.runtime
}
let wasmRuntimeArgs = []
const quotes = process.platform === "win32" ? '\'' : ''
switch (wasmRuntime) {
case 'wasmtime':
wasmRuntimeArgs = ['--args', '-e WASMTIME_BACKTRACE_DETAILS=1', '/wasi-runtimes/wasmtime/bin/wasmtime-pwd.sh',]
wasmRuntimeArgs = ['--args', `${quotes}-e WASMTIME_BACKTRACE_DETAILS=1${quotes}`, 'wasmtime-pwd.sh',]
break
case 'wasmer':
wasmRuntimeArgs = ['sudo', '/wasi-runtimes/wasmer/bin/wasmer-pwd.sh',]
wasmRuntimeArgs = ['sudo', 'wasmer-pwd.sh',]
break
case 'wasm3':
wasmRuntimeArgs = ['/wasi-runtimes/wasm3/bin/wasm3',]
wasmRuntimeArgs = ['wasm3',]
break
case 'wavm':
wasmRuntimeArgs = ['/wasi-runtimes/wavm/bin/wavm', 'run']
wasmRuntimeArgs = ['wavm', 'run']
break
default:
throw Error('unexpected wasm runtime')
}

if(process.platform === "win32"){
var dockerRun = spawnSync('"C:\\Program Files\\Git\\bin\\sh.exe"',
["--login", "-i", "-c", `"${buildDir}/itk-wasm-build-env ` + wasmRuntimeArgs + wasmBinaryRelativePath + wasmBinaryArgs + '"'], {
["--login", "-i", "-c", `"${buildDir}/itk-wasm-build-env ${wasmRuntimeArgs.join(' ')} ${wasmBinaryRelativePath} ${wasmBinaryArgs.join(' ')}"`], {
env: process.env,
stdio: 'inherit',
shell: true
Expand Down

0 comments on commit 21f6b9a

Please sign in to comment.