Merge pull request #11436 from atom/jf-allow-window-envs-to-be-updated-from-term

Allow A Window's Environment To Reflect The Most Recent atom Invocation
This commit is contained in:
Lee Dohm
2016-04-12 11:30:07 -07:00
4 changed files with 20 additions and 3 deletions

View File

@@ -466,6 +466,7 @@ class AtomApplication
openedWindow.restore()
else
openedWindow.focus()
openedWindow.replaceEnvironment(env)
else
if devMode
try

View File

@@ -68,6 +68,7 @@ class AtomWindow
@loaded = true
@setLoadSettings(loadSettings)
@env = loadSettings.env if loadSettings.env?
@browserWindow.focusOnWebView() if @isSpec
@browserWindow.temporaryState = {windowDimensions} if windowDimensions?
@@ -169,6 +170,9 @@ class AtomWindow
else
@browserWindow.once 'window:loaded', => @openLocations(locationsToOpen)
replaceEnvironment: (env) ->
@browserWindow.webContents.send 'environment', env
sendMessage: (message, detail) ->
@browserWindow.webContents.send 'message', message, detail

View File

@@ -91,4 +91,12 @@ function normalize (options = {}) {
}
}
export default { getFromShell, needsPatching, normalize }
function replace (env) {
if (!env || !env.PATH) {
return
}
process.env = env
}
export default { getFromShell, needsPatching, normalize, replace }

View File

@@ -4,11 +4,12 @@ module.exports = ({blobStore}) ->
path = require 'path'
require './window'
{getWindowLoadSettings} = require './window-load-settings-helpers'
{ipcRenderer} = require 'electron'
{resourcePath, isSpec, devMode, env} = getWindowLoadSettings()
# Set baseline environment
environmentHelpers.normalize({env: env})
env = process.env
# Add application-specific exports to module search path.
exportsPath = path.join(resourcePath, 'exports')
@@ -25,7 +26,7 @@ module.exports = ({blobStore}) ->
applicationDelegate: new ApplicationDelegate,
configDirPath: process.env.ATOM_HOME
enablePersistence: true
env: env
env: process.env
})
atom.startEditorWindow().then ->
@@ -35,3 +36,6 @@ module.exports = ({blobStore}) ->
window.removeEventListener('focus', windowFocused)
setTimeout (-> document.querySelector('atom-workspace').focus()), 0
window.addEventListener('focus', windowFocused)
ipcRenderer.on('environment', (event, env) ->
environmentHelpers.replace(env)
)