Bug 1511079 - Don't apply the node wrapper for npm when on windows. r=ahal
authorMark Banner <standard8@mozilla.com>
Thu, 29 Nov 2018 21:41:13 +0000
changeset 448965 77f0c6b51d009e85a366998fe694a9b3c35ca2c6
parent 448964 6feb94524b7e519e720d7cccc3fa9cccc51f904e
child 448966 e9eedbf1bd4b6ed0bdd07118ae9447570270af79
push id35139
push userccoroiu@mozilla.com
push dateSat, 01 Dec 2018 02:30:08 +0000
treeherdermozilla-central@22425b629a9d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1511079
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1511079 - Don't apply the node wrapper for npm when on windows. r=ahal Differential Revision: https://phabricator.services.mozilla.com/D13456
python/mozbuild/mozbuild/nodeutil.py
tools/lint/eslint/setup_helper.py
--- a/python/mozbuild/mozbuild/nodeutil.py
+++ b/python/mozbuild/mozbuild/nodeutil.py
@@ -48,18 +48,18 @@ def find_node_paths():
 
 
 def check_executable_version(exe, wrap_call_with_node=False):
     """Determine the version of a Node executable by invoking it.
 
     May raise ``subprocess.CalledProcessError`` or ``ValueError`` on failure.
     """
     out = None
-    # npm may be a script, so we must call it with node.
-    if wrap_call_with_node:
+    # npm may be a script (Except on Windows), so we must call it with node.
+    if wrap_call_with_node and platform.system() != "Windows":
         binary, _ = find_node_executable()
         if binary:
             out = subprocess.check_output([binary, exe, "--version"]).lstrip('v').rstrip()
 
     # If we can't find node, or we don't need to wrap it, fallback to calling
     # direct.
     if not out:
         out = subprocess.check_output([exe, "--version"]).lstrip('v').rstrip()
--- a/tools/lint/eslint/setup_helper.py
+++ b/tools/lint/eslint/setup_helper.py
@@ -101,20 +101,25 @@ def eslint_setup(should_clobber=False):
     package_lock_json_path = os.path.join(get_project_root(), "package-lock.json")
     package_lock_json_tmp_path = os.path.join(tempfile.gettempdir(), "package-lock.json.tmp")
 
     # If we have an npm version newer than 5.8.0, just use 'ci', as that's much
     # simpler and does exactly what we want.
     npm_is_older_version = version < StrictVersion("5.8.0").version
 
     if npm_is_older_version:
-        cmd = [node_path, npm_path, "install"]
+        cmd = [npm_path, "install"]
         shutil.copy2(package_lock_json_path, package_lock_json_tmp_path)
     else:
-        cmd = [node_path, npm_path, "ci"]
+        cmd = [npm_path, "ci"]
+
+    # On non-Windows, ensure npm is called via node, as node may not be in the
+    # path.
+    if platform.system() != "Windows":
+        cmd.insert(0, node_path)
 
     cmd.extend(extra_parameters)
     print("Installing eslint for mach using \"%s\"..." % (" ".join(cmd)))
     result = call_process("eslint", cmd)
 
     if npm_is_older_version:
         shutil.move(package_lock_json_tmp_path, package_lock_json_path)