Patch process.env on startup

This commit is contained in:
Lee Dohm
2016-03-07 16:43:20 -08:00
committed by Joe Fitzgerald
parent 6bf785faa0
commit 8c53e25f80
2 changed files with 17 additions and 0 deletions

View File

@@ -362,3 +362,16 @@ describe "AtomEnvironment", ->
version = '1.7.0-dev-5340c91'
expect(atom.getReleaseChannel()).toBe 'dev'
describe "environment patching", ->
it "patches process.env on startup", ->
configDirPath = temp.mkdirSync()
fakeDocument = {
addEventListener: ->
removeEventListener: ->
head: document.createElement('head')
body: document.createElement('body')
}
atomEnvironment = new AtomEnvironment({applicationDelegate: atom.applicationDelegate, window, document: fakeDocument})
expect(process.env).toEqual atomEnvironment.project.getEnv()

View File

@@ -230,6 +230,10 @@ class AtomEnvironment extends Model
checkPortableHomeWritable()
# Patch the `process.env` on startup to fix the problem first documented
# in #4126
process.env = @project.getEnv()
attachSaveStateListeners: ->
saveState = => @saveState({isUnloading: false}) unless @unloaded
debouncedSaveState = _.debounce(saveState, @saveStateDebounceInterval)