Fixes #1728. Remove Shell-Env from Executable, use Atom's process.env instead

Atom has builtin a fix for the process.env being out of sync with
the user's actual environment variables. It is similar to how Shell-Env works
which Atom-Beautify was using. Now we no longer need it.

However, there is still an issue when running specs. Thus, Atom-Beautify
specs still patch process.env with Shell-Env.
See https://discuss.atom.io/t/specs-do-not-load-shell-environment-variables-activationhooks-core-loaded-shell-environment/44199
for details.
This commit is contained in:
Glavin Wiechert 2017-06-21 20:39:40 -03:00
parent bfef1d35e7
commit 75f63293d4
3 changed files with 11 additions and 9 deletions

View File

@ -193,6 +193,9 @@
"winston": "2.3.1",
"yaml-front-matter": "3.4.0"
},
"activationHooks": [
"core:loaded-shell-environment"
],
"activationCommands": {
"atom-workspace": [
"atom-beautify:help-debug-editor",

View File

@ -4,6 +4,10 @@ beautifier = new Beautifiers()
fs = require "fs"
path = require "path"
JsDiff = require('diff')
shellEnv = require('shell-env')
# Fix https://discuss.atom.io/t/specs-do-not-load-shell-environment-variables-activationhooks-core-loaded-shell-environment/44199
process.env = shellEnv.sync()
# Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
#

View File

@ -4,7 +4,6 @@ which = require('which')
spawn = require('child_process').spawn
path = require('path')
semver = require('semver')
shellEnv = require('shell-env')
os = require('os')
fs = require('fs')
@ -324,15 +323,11 @@ class Executable
@_envCache = null
shellEnv: () ->
@constructor.shellEnv()
env = @constructor.shellEnv()
@debug("env", env)
return env
@shellEnv: () ->
if @_envCache
return Promise.resolve(@_envCache)
else
shellEnv()
.then((env) =>
@_envCache = env
)
Promise.resolve(process.env)
###
Like the unix which utility.