Bug 1368656 - Fix ./mach eslint on windows - add a return in the for loop when trying extensions to ensure we get the right one. r?florian draft
authorMark Banner <standard8@mozilla.com>
Tue, 30 May 2017 14:14:01 +0100
changeset 586463 c372261a2e84eb07b9b2b243f44ba66a602d3a38
parent 586049 34ac1a5d6576d6775491c8a882710a1520551da6
child 630992 dbda3725e8ee5a2458d7d6bb74a6cd287ec89c68
push id61410
push userbmo:standard8@mozilla.com
push dateTue, 30 May 2017 13:14:13 +0000
reviewersflorian
bugs1368656
milestone55.0a1
Bug 1368656 - Fix ./mach eslint on windows - add a return in the for loop when trying extensions to ensure we get the right one. r?florian MozReview-Commit-ID: FSXANgWWugE
tools/lint/eslint/setup_helper.py
--- a/tools/lint/eslint/setup_helper.py
+++ b/tools/lint/eslint/setup_helper.py
@@ -245,33 +245,31 @@ def get_possible_node_paths_win():
         os.path.join(os.environ.get("PROGRAMFILES"), "nodejs")
     })
 
 
 def which_path(filename):
     """
     Return the nodejs or npm path.
     """
-    path = None
-
     if platform.system() == "Windows":
         for ext in [".cmd", ".exe", ""]:
             try:
-                path = which.which(filename + ext, path=get_possible_node_paths_win())
+                return which.which(filename + ext, path=get_possible_node_paths_win())
             except which.WhichError:
                 pass
     else:
         try:
-            path = which.which(filename)
+            return which.which(filename)
         except which.WhichError:
             if filename == "node":
                 # Retry it with "nodejs" as Linux tends to prefer nodejs rather than node.
                 return which_path("nodejs")
 
-    return path
+    return None
 
 
 def get_node_or_npm_path(filename, minversion=None):
     node_or_npm_path = which_path(filename)
 
     if not node_or_npm_path:
         if filename in ('node', 'nodejs'):
             print(NODE_NOT_FOUND_MESSAGE)