From fbbbf13e49dea07d192ec4c75627afa7eddfb65c Mon Sep 17 00:00:00 2001 From: Todd Bluhm Date: Tue, 6 Dec 2016 21:32:09 -0800 Subject: [PATCH] Add system env vars back into the env list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- lib/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 91a7b04..4042f18 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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