Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit e663d05

Browse files
committed
fixes for headless commands with "args with spaces"
Fixes #954
1 parent c6ec488 commit e663d05

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

app/bin/fsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ ROOTDIR="$DIR/.."
2424
# determine which argv to ignore
2525
export DEVMODE=true
2626

27-
exec "$ROOTDIR/node_modules/.bin/electron" "$ROOTDIR" --fsh-headless $@
27+
exec "$ROOTDIR/node_modules/.bin/electron" "$ROOTDIR" --fsh-headless "$@"

app/headless.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ const main = (app, mainFunctions) => {
636636
//
637637
// execute a single command from the CLI
638638
//
639-
const cmd = argv.join(' ').trim()
639+
const cmd = argv.map(_ => _.match(/\s+/) ? `"${_}"` : _).join(' ').trim()
640640
if (cmd && cmd.length > 0) {
641641
debug('about to execute command')
642642
return Promise.resolve().then(() => eval(cmd)).catch(maybeRetry)

tests/tests/passes/02/headless.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,13 @@ describe('Headless mode', function() {
133133
it('should create an action with an env var parameter', () => cli.do('action create envfun ./data/echo.js -p fun $FUN', { FUN: 3 })
134134
.then(cli.expectOK('ok: updated action envfun\n', { exact: true }))
135135
.catch(common.oops(this)))
136+
137+
it('should create an action with params-with-spaces', () => cli.do('action create spacey ./data/echo.js -p fun "space cadet"')
138+
.then(cli.expectOK('ok: updated action spacey\n', { exact: true }))
139+
.catch(common.oops(this)))
140+
141+
it('should invoke spacey', () => cli.do('action invoke spacey')
142+
.then(cli.expectOK('fun: "space cadet"'))
143+
.catch(common.oops(this)))
144+
136145
})

0 commit comments

Comments
 (0)