🎨 Fix spec, cleanup

This commit is contained in:
Joe Fitzgerald 2016-11-14 16:29:13 -07:00
parent d0a011e93a
commit 3123a92687
No known key found for this signature in database
GPG Key ID: 3FAE73BF9E8A848C
2 changed files with 14 additions and 12 deletions

View File

@ -205,7 +205,7 @@ describe('updateProcessEnv(launchEnv)', function () {
process.env = {FOO: 'bar'}
await updateProcessEnv(process.env)
expect(child_process.execFile).not.toHaveBeenCalled()
expect(child_process.spawn).not.toHaveBeenCalled()
expect(process.env).toEqual({FOO: 'bar'})
})
})

View File

@ -101,18 +101,20 @@ async function getEnvFromShell (env) {
console.log(error)
}
if (stdout && stdout.trim() !== '') {
let result = {}
for (let line of stdout.split('\n')) {
if (line.includes('=')) {
let components = line.split('=')
let key = components.shift()
let value = components.join('=')
result[key] = value
}
}
return result
if (!stdout || stdout.trim() === '') {
return null
}
let result = {}
for (let line of stdout.split('\n')) {
if (line.includes('=')) {
let components = line.split('=')
let key = components.shift()
let value = components.join('=')
result[key] = value
}
}
return result
}
export default { updateProcessEnv, shouldGetEnvFromShell }