Bug 1262978: Run npm to get the path to installed binaries if eslint can't otherwise be found. r=gps
authorDave Townsend <dtownsend@oxymoronical.com>
Thu, 07 Apr 2016 13:18:40 -0700
changeset 292339 7ddc5c22f1322e3c5992704f06901278dbd9c7d0
parent 292338 9c492faa4c397c9fd2a9448fce84117d0e2f8a2a
child 292340 2b2647fba6ce13884e8f0487f23e7323d67e5061
push id30155
push userkwierso@gmail.com
push dateFri, 08 Apr 2016 22:27:01 +0000
treeherdermozilla-central@705c5fb32d49 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1262978
milestone48.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 1262978: Run npm to get the path to installed binaries if eslint can't otherwise be found. r=gps MozReview-Commit-ID: HFWID6QhpS2
python/mach_commands.py
--- 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}')