Skip to content

Commit a459744

Browse files
author
Hugo Wood
committedMar 15, 2017
feat(spawn): add support for quoted scripts
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 kentcdodds#77. BREAKING CHANGE: Changes the behavior when passed quoted scripts or special characters interpreted by the shell.
1 parent 5a6e3b8 commit a459744

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"cross-env": "dist/bin/cross-env.js"
88
},
99
"engines": {
10-
"node": ">=4.0"
10+
"node": ">=4.8"
1111
},
1212
"scripts": {
1313
"start": "nps",

‎src/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ const envSetterRegex = /(\w+)=('(.+)'|"(.+)"|(.+))/
88
function crossEnv(args) {
99
const [command, commandArgs, env] = getCommandArgsAndEnvVars(args)
1010
if (command) {
11-
const proc = spawn(command, commandArgs, {stdio: 'inherit', env})
11+
const proc = spawn(command, commandArgs, {
12+
stdio: 'inherit',
13+
shell: true,
14+
env,
15+
})
1216
process.on('SIGTERM', () => proc.kill('SIGTERM'))
1317
process.on('SIGINT', () => proc.kill('SIGINT'))
1418
process.on('SIGBREAK', () => proc.kill('SIGBREAK'))

‎src/index.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ function testEnvSetting(expected, ...envSettings) {
8080
expect(crossSpawnMock.spawn).toHaveBeenCalledTimes(1)
8181
expect(crossSpawnMock.spawn).toHaveBeenCalledWith('echo', ['hello world'], {
8282
stdio: 'inherit',
83+
shell: true,
8384
env: Object.assign({}, process.env, env),
8485
})
8586

0 commit comments

Comments
 (0)