Comparing version 5.1.0 to 5.1.1
@@ -22,2 +22,3 @@ 'use strict'; | ||
* @param {String} command Command to convert | ||
* @param {Object} env Map of the current environment variable names and their values | ||
* @param {boolean} normalize If the command should be normalized using `path` | ||
@@ -28,4 +29,4 @@ * after converting | ||
function commandConvert(command) { | ||
var normalize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
function commandConvert(command, env) { | ||
var normalize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
@@ -36,3 +37,10 @@ if (!(0, _isWindows2.default)()) { | ||
var envUnixRegex = /\$(\w+)|\${(\w+)}/g; // $my_var or ${my_var} | ||
var convertedCmd = command.replace(envUnixRegex, '%$1$2%'); | ||
var convertedCmd = command.replace(envUnixRegex, function (match, $1, $2) { | ||
var varName = $1 || $2; | ||
// In Windows, non-existent variables are not replaced by the shell, | ||
// so for example "echo %FOO%" will literally print the string "%FOO%", as | ||
// opposed to printing an empty string in UNIX. See kentcdodds/cross-env#145 | ||
// If the env variable isn't defined at runtime, just strip it from the command entirely | ||
return env[varName] ? `%${varName}%` : ''; | ||
}); | ||
// Normalization is required for commands with relative paths | ||
@@ -39,0 +47,0 @@ // For example, `./cmd.bat`. See kentcdodds/cross-env#127 |
@@ -30,13 +30,14 @@ 'use strict'; | ||
var env = getEnvVars(envSetters); | ||
if (command) { | ||
var proc = (0, _crossSpawn.spawn)( | ||
// run `path.normalize` for command(on windows) | ||
(0, _command2.default)(command, true), | ||
(0, _command2.default)(command, env, true), | ||
// by default normalize is `false`, so not run for cmd args | ||
commandArgs.map(function (arg) { | ||
return (0, _command2.default)(arg); | ||
return (0, _command2.default)(arg, env); | ||
}), { | ||
stdio: 'inherit', | ||
shell: options.shell, | ||
env: getEnvVars(envSetters) | ||
env | ||
}); | ||
@@ -43,0 +44,0 @@ process.on('SIGTERM', function () { |
{ | ||
"name": "cross-env", | ||
"version": "5.1.0", | ||
"version": "5.1.1", | ||
"description": "Run scripts that set and use environment variables across platforms", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
24509
189