Bug 1228761 - 'mach eslint' should look for 'nodejs' as well as 'node' executables to better support linux. r?ahal draft
authorMark Banner <standard8@mozilla.com>
Fri, 11 Nov 2016 17:15:40 +0000
changeset 438571 412107ee97e4af4df21352b2548f52eec31dca64
parent 437787 d284cdb3ad6e0609a53a275df6efcff4255c30ec
child 536953 b4dca6470f65a55c16ef65cb735b232f3eb709fb
push id35768
push userbmo:standard8@mozilla.com
push dateMon, 14 Nov 2016 20:22:07 +0000
reviewersahal
bugs1228761
milestone52.0a1
Bug 1228761 - 'mach eslint' should look for 'nodejs' as well as 'node' executables to better support linux. r?ahal MozReview-Commit-ID: 768u0MyMWA0
tools/lint/eslint.lint
--- a/tools/lint/eslint.lint
+++ b/tools/lint/eslint.lint
@@ -208,32 +208,34 @@ def get_node_or_npm_path(filename, minve
             except which.WhichError:
                 pass
     else:
         try:
             node_or_npm_path = which.which(filename)
             if is_valid(node_or_npm_path, minversion):
                 return node_or_npm_path
         except which.WhichError:
-            pass
+            if filename == "node":
+                # Retry it with "nodejs" as Linux tends to prefer nodejs rather than node.
+                return get_node_or_npm_path("nodejs", minversion)
 
-    if filename == "node":
+    if filename in ('node', 'nodejs'):
         print(NODE_NOT_FOUND_MESSAGE)
     elif filename == "npm":
         print(NPM_NOT_FOUND_MESSAGE)
 
     if platform.system() == "Windows":
         app_paths = get_possible_node_paths_win()
 
         for p in app_paths:
             print("  - %s" % p)
     elif platform.system() == "Darwin":
-        print("  - /usr/local/bin/node")
+        print("  - /usr/local/bin/{}".format(filename))
     elif platform.system() == "Linux":
-        print("  - /usr/bin/nodejs")
+        print("  - /usr/bin/{}".format(filename))
 
     return None
 
 
 def is_valid(path, minversion=None):
     try:
         version_str = subprocess.check_output([path, "--version"],
                                               stderr=subprocess.STDOUT)