Skip to content
This repository has been archived by the owner on Jan 6, 2021. It is now read-only.

Commit

Permalink
feat(spawn): support for quoted scripts
Browse files Browse the repository at this point in the history
Use the shell option of spawn introduced in Node.js 4.8 (see
nodejs/node#4598) to pass the command to the OS shell.
Supersedes #77.

BREAKING CHANGE: Changes the behavior when passed quoted scripts or special characters interpreted
by the shell.
  • Loading branch information
Hugo Wood committed Mar 15, 2017
1 parent 5a6e3b8 commit 390baad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"cross-env": "dist/bin/cross-env.js"
},
"engines": {
"node": ">=4.0"
"node": ">=4.8"
},
"scripts": {
"start": "nps",
Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ const envSetterRegex = /(\w+)=('(.+)'|"(.+)"|(.+))/
function crossEnv(args) {
const [command, commandArgs, env] = getCommandArgsAndEnvVars(args)
if (command) {
const proc = spawn(command, commandArgs, {stdio: 'inherit', env})
const proc = spawn(command, commandArgs, {
stdio: 'inherit',
shell: true,
env,
})
process.on('SIGTERM', () => proc.kill('SIGTERM'))
process.on('SIGINT', () => proc.kill('SIGINT'))
process.on('SIGBREAK', () => proc.kill('SIGBREAK'))
Expand Down
1 change: 1 addition & 0 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function testEnvSetting(expected, ...envSettings) {
expect(crossSpawnMock.spawn).toHaveBeenCalledTimes(1)
expect(crossSpawnMock.spawn).toHaveBeenCalledWith('echo', ['hello world'], {
stdio: 'inherit',
shell: true,
env: Object.assign({}, process.env, env),
})

Expand Down

0 comments on commit 390baad

Please sign in to comment.