mirror of
https://github.com/toddbluhm/env-cmd.git
synced 2025-12-08 18:23:33 +00:00
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:
parent
f37249e467
commit
fbbbf13e49
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user