cross-spawn
Advanced tools
Comparing version 3.0.1 to 4.0.0
@@ -6,2 +6,3 @@ 'use strict'; | ||
var resolveCommand = require('./resolveCommand'); | ||
var hasBrokenSpawn = require('./hasBrokenSpawn'); | ||
@@ -78,2 +79,6 @@ var isWin = process.platform === 'win32'; | ||
function requiresShell(command) { | ||
return !/\.(?:com|exe)$/i.test(command); | ||
} | ||
function parse(command, args, options) { | ||
@@ -84,2 +89,3 @@ var shebang; | ||
var original; | ||
var shell; | ||
@@ -101,2 +107,3 @@ // Normalize arguments, similar to nodejs | ||
shebang = file && readShebang(file); | ||
shell = options.shell || hasBrokenSpawn; | ||
@@ -106,17 +113,22 @@ if (shebang) { | ||
command = shebang; | ||
shell = shell || requiresShell(resolveCommand(shebang) || resolveCommand(shebang, true)); | ||
} else { | ||
shell = shell || requiresShell(file); | ||
} | ||
// Escape command & arguments | ||
applyQuotes = command !== 'echo'; // Do not quote arguments for the special "echo" command | ||
command = escapeCommand(command); | ||
args = args.map(function (arg) { | ||
return escapeArg(arg, applyQuotes); | ||
}); | ||
if (shell) { | ||
// Escape command & arguments | ||
applyQuotes = (command !== 'echo'); // Do not quote arguments for the special "echo" command | ||
command = escapeCommand(command); | ||
args = args.map(function (arg) { | ||
return escapeArg(arg, applyQuotes); | ||
}); | ||
// Use cmd.exe | ||
args = ['/s', '/c', '"' + command + (args.length ? ' ' + args.join(' ') : '') + '"']; | ||
command = process.env.comspec || 'cmd.exe'; | ||
// Use cmd.exe | ||
args = ['/s', '/c', '"' + command + (args.length ? ' ' + args.join(' ') : '') + '"']; | ||
command = process.env.comspec || 'cmd.exe'; | ||
// Tell node's spawn that the arguments are already escaped | ||
options.windowsVerbatimArguments = true; | ||
// Tell node's spawn that the arguments are already escaped | ||
options.windowsVerbatimArguments = true; | ||
} | ||
} | ||
@@ -123,0 +135,0 @@ |
{ | ||
"name": "cross-spawn", | ||
"version": "3.0.1", | ||
"version": "4.0.0", | ||
"description": "Cross platform child_process#spawn and child_process#spawnSync", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -56,3 +56,10 @@ # cross-spawn | ||
## Caveat | ||
On Windows, cross-spawn will only spawn `cmd.exe` if necessary. If the extension | ||
of the executable is `.exe` or `.com`, it will spawn it directly. If you wish | ||
to override this behavior and *always* spawn a shell, pass the `{shell: true}` | ||
option. | ||
## Tests | ||
@@ -59,0 +66,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15353
15
243
72
56
2
2
2
2