Bug 1262978: Run npm to get the path to installed binaries if eslint can't otherwise be found. r?gps
MozReview-Commit-ID: HFWID6QhpS2
--- a/python/mach_commands.py
+++ b/python/mach_commands.py
@@ -161,17 +161,28 @@ class MachCommands(MachCommandBase):
return self.eslint_setup()
if not binary:
binary = os.environ.get('ESLINT', None)
if not binary:
try:
binary = which.which('eslint')
except which.WhichError:
- pass
+ npmPath = self.getNodeOrNpmPath("npm")
+ if npmPath:
+ try:
+ output = subprocess.check_output([npmPath, "bin", "-g"],
+ stderr=subprocess.STDOUT)
+ if minversion:
+ base = output.split("\n").strip()
+ binary = os.path.join(base, "eslint")
+ if not os.path.is_file(binary):
+ binary = None
+ except (subprocess.CalledProcessError, WindowsError):
+ pass
if not binary:
print(ESLINT_NOT_FOUND_MESSAGE)
return 1
self.log(logging.INFO, 'eslint', {'binary': binary, 'args': args},
'Running {binary}')