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
--- 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)