]> khamidou — GitHub mirrors - electron.git/commitdiff
module: remove system paths from search
authordeepak1556 <hop2deep@gmail.com>
Mon, 20 Apr 2015 09:57:51 +0000 (15:27 +0530)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 23 Apr 2015 04:55:34 +0000 (12:55 +0800)
atom/browser/lib/init.coffee

index 9ef590dc62650eb777713598090ee795422749e8..8bd264cf5f837fec37d96877ff8fb704a4ba2913 100644 (file)
@@ -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')