From: deepak1556 Date: Mon, 20 Apr 2015 09:57:51 +0000 (+0530) Subject: module: remove system paths from search X-Git-Tag: v0.25.1~5 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=4983ef77bd3382c6c05e31a33b95621abbe5bc69;p=electron.git module: remove system paths from search --- diff --git a/atom/browser/lib/init.coffee b/atom/browser/lib/init.coffee index 9ef590dc..8bd264cf 100644 --- a/atom/browser/lib/init.coffee +++ b/atom/browser/lib/init.coffee @@ -9,6 +9,25 @@ process.argv.splice 1, 1 # Add browser/api/lib to require's search paths, # which contains javascript part of Atom's built-in libraries. +homeDir = + if process.platform is 'win32' + process.env.USERPROFILE + else + process.env.HOME + +syspath = [] + +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')