Bug 1369710 - [mozlint] Ensure that a valid path is entered. r=ahal
authorDyex <Dyex719@gmail.com>
Tue, 08 Aug 2017 19:20:31 +0530
changeset 373388 9f2c22f4ef01
parent 373387 32452cb511f5
child 373389 8b22f1b5e9f3
push id93503
push userahalberstadt@mozilla.com
push dateTue, 08 Aug 2017 15:20:28 +0000
treeherdermozilla-inbound@9f2c22f4ef01 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1369710
milestone57.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 1369710 - [mozlint] Ensure that a valid path is entered. r=ahal MozReview-Commit-ID: 6HOE9hmOkCx
python/mozlint/mozlint/cli.py
--- a/python/mozlint/mozlint/cli.py
+++ b/python/mozlint/mozlint/cli.py
@@ -108,16 +108,22 @@ def find_linters(linters=None):
 
 
 def run(paths, linters, fmt, outgoing, workdir, **lintargs):
     from mozlint import LintRoller, formatters
 
     lint = LintRoller(**lintargs)
     lint.read(find_linters(linters))
 
+    # Check if the path that is entered is a valid one.
+    invalid_paths = [path for path in paths if not os.path.exists(path)]
+    if invalid_paths:
+        print("Error: The following paths do not exist:\n{}".format("\n".join(invalid_paths)))
+        return 1
+
     # run all linters
     results = lint.roll(paths, outgoing=outgoing, workdir=workdir)
     formatter = formatters.get(fmt)
 
     # Encode output with 'replace' to avoid UnicodeEncodeErrors on
     # environments that aren't using utf-8.
     print(formatter(results, failed=lint.failed).encode(
         sys.stdout.encoding or 'ascii', 'replace'))