Simplify how we remove user-defined search paths
This commit is contained in:
parent
4983ef77bd
commit
fad977e27d
1 changed files with 9 additions and 16 deletions
|
@ -7,28 +7,21 @@ util = require 'util'
|
||||||
# we need to restore it here.
|
# we need to restore it here.
|
||||||
process.argv.splice 1, 1
|
process.argv.splice 1, 1
|
||||||
|
|
||||||
# Add browser/api/lib to require's search paths,
|
# Global module search paths.
|
||||||
# which contains javascript part of Atom's built-in libraries.
|
globalPaths = module.globalPaths
|
||||||
|
|
||||||
|
# Don't lookup modules in user-defined search paths, see http://git.io/vf8sF.
|
||||||
homeDir =
|
homeDir =
|
||||||
if process.platform is 'win32'
|
if process.platform is 'win32'
|
||||||
process.env.USERPROFILE
|
process.env.USERPROFILE
|
||||||
else
|
else
|
||||||
process.env.HOME
|
process.env.HOME
|
||||||
|
if homeDir # Node only add user-defined search paths when $HOME is defined.
|
||||||
|
userModulePath = path.resolve homeDir, '.node_modules'
|
||||||
|
globalPaths.splice globalPaths.indexOf(userModulePath), 2
|
||||||
|
|
||||||
syspath = []
|
# Add browser/api/lib to module search paths, which contains javascript part of
|
||||||
|
# Electron's built-in libraries.
|
||||||
if homeDir
|
|
||||||
syspath.push(path.resolve(homeDir, '.node_modules'))
|
|
||||||
syspath.push(path.resolve(homeDir, '.node_libraries'))
|
|
||||||
|
|
||||||
# Remove system paths from module lookups as it may contain modules not
|
|
||||||
# shipped with the app or compiled with wrong v8 headers.
|
|
||||||
syspath.map (path) ->
|
|
||||||
index = module.globalPaths.indexOf path
|
|
||||||
if index > -1
|
|
||||||
module.globalPaths.splice(index,1)
|
|
||||||
|
|
||||||
globalPaths = module.globalPaths
|
|
||||||
globalPaths.push path.resolve(__dirname, '..', 'api', 'lib')
|
globalPaths.push path.resolve(__dirname, '..', 'api', 'lib')
|
||||||
|
|
||||||
# Import common settings.
|
# Import common settings.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue