]> khamidou — GitHub mirrors - electron.git/commitdiff
compile-coffee.py searches for node even on non-windows systems
authorAndy Dill <andy.dill@gmail.com>
Fri, 17 Apr 2015 16:33:00 +0000 (09:33 -0700)
committerAndy Dill <andy.dill@gmail.com>
Sat, 16 May 2015 05:35:49 +0000 (22:35 -0700)
tools/compile-coffee.py

index c7eb3fccba66e598fdce2bc1a7e5f7750afac053..5b7a17c8771669acf368cc3dbee9b99a602f2734 100755 (executable)
@@ -10,6 +10,11 @@ WINDOWS_NODE_PATHs = [
   'C:/Program Files (x86)/nodejs',
   'C:/Program Files/nodejs',
 ] + os.environ['PATH'].split(os.pathsep)
+NIX_NODE_PATHs = [
+  '/usr/local/bin',
+  '/usr/bin',
+  '/bin',
+] + os.environ['PATH'].split(os.pathsep)
 
 
 def main():
@@ -18,20 +23,24 @@ def main():
 
   coffee = os.path.join(SOURCE_ROOT, 'node_modules', 'coffee-script', 'bin',
                         'coffee')
+
+  node = 'node'
   if sys.platform in ['win32', 'cygwin']:
-    node = find_node()
-    if not node:
-      print 'Node.js not found in PATH for building atom-shell'
-      return 1
-    subprocess.check_call(['node', coffee, '-c', '-o', output_dir, input_file],
-                          executable=node)
+    node = find_node(WINDOWS_NODE_PATHs, 'node.exe')
   else:
-    subprocess.check_call(['node', coffee, '-c', '-o', output_dir, input_file])
+    node = find_node(NIX_NODE_PATHs, 'node')
+
+  if not node:
+    print 'Node.js not found in PATH for building electron'
+    return 1
+
+  subprocess.check_call(['node', coffee, '-c', '-o', output_dir, input_file],
+                        executable=node)
 
 
-def find_node():
-  for path in WINDOWS_NODE_PATHs:
-    full_path = os.path.join(path, 'node.exe')
+def find_node(paths, target):
+  for path in paths:
+    full_path = os.path.join(path, target)
     if os.path.exists(full_path):
       return full_path
   return None