Add system env vars back into the env list

- After retrieving user set envs from a file, add the system envs back
into the envs object so that envs like PATH, etc… will exist for the
spawned command
This commit is contained in:
Todd Bluhm 2016-12-06 21:32:09 -08:00
parent f37249e467
commit fbbbf13e49
No known key found for this signature in database
GPG Key ID: 9CF312607477B8AB

View File

@ -10,7 +10,10 @@ function EnvCmd (args) {
const parsedArgs = ParseArgs(args)
// If a .rc file was found then use that
const env = fs.existsSync(rcFileLocation) ? UseRCFile(parsedArgs) : UseCmdLine(parsedArgs)
let env = fs.existsSync(rcFileLocation) ? UseRCFile(parsedArgs) : UseCmdLine(parsedArgs)
// Add in the system environment variables to our environment list
env = Object.assign({}, process.env, env)
// Execute the command with the given environment variables
const proc = spawn(parsedArgs.command, parsedArgs.commandArgs, {
@ -117,7 +120,7 @@ function UseCmdLine (parsedArgs) {
// Parse the env file string using the correct parser
const env = ext === '.json' || ext === '.js'
? Object.assign({}, process.env, require(envFilePath))
? require(envFilePath)
: ParseEnvString(file)
return env