Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/scripts/lint_javascript.py |
| diff --git a/third_party/WebKit/Source/devtools/scripts/lint_javascript.py b/third_party/WebKit/Source/devtools/scripts/lint_javascript.py |
| index 9b8e77eb1eaddf8fd1a51201ee293e2e2e7ac49b..70a9c890651ff59a0c7cc8fdbf2bd5013c07dbf6 100755 |
| --- a/third_party/WebKit/Source/devtools/scripts/lint_javascript.py |
| +++ b/third_party/WebKit/Source/devtools/scripts/lint_javascript.py |
| @@ -4,12 +4,13 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| -import os |
| import os.path as path |
| import re |
| import subprocess |
| import sys |
| +import install_node_deps |
| + |
| files_to_lint = None |
| if len(sys.argv) >= 2: |
| @@ -48,37 +49,16 @@ def to_platform_path_exact(filepath): |
| scripts_path = path.dirname(path.abspath(__file__)) |
| devtools_path = path.dirname(scripts_path) |
| devtools_frontend_path = path.join(devtools_path, "front_end") |
| - |
| - |
| -# Based on http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python. |
| -def which(program): |
| - def is_exe(fpath): |
| - return path.isfile(fpath) and os.access(fpath, os.X_OK) |
| - |
| - fpath, fname = path.split(program) |
| - if fpath: |
| - if is_exe(program): |
| - return program |
| - else: |
| - for part in os.environ["PATH"].split(os.pathsep): |
| - part = part.strip("\"") |
| - exe_file = path.join(part, program) |
| - if is_exe(exe_file): |
| - return exe_file |
| - return None |
| - |
| +eslint_path = path.join(devtools_path, "node_modules", ".bin", "eslint") |
|
lushnikov
2016/10/05 16:22:49
who's responsible for installing eslint?
chenwilliam
2016/10/05 17:59:19
'npm install' is run as part of the PRESUBMIT scri
|
| print("Linting JavaScript with eslint...\n") |
| def js_lint(files_list=None): |
| eslint_errors_found = False |
| - |
| - eslint_path = which("eslint") |
| - if not eslint_path: |
| - print("!! NOTE: Skipping JavaScript linting because eslint is not installed.") |
| - print("!! npm install -g eslint") |
| - eslint_errors_found = False # Linting is opt-in for now, so this is a soft failure |
| + if not path.isfile(eslint_path): |
| + print("Failed to run eslint, run ./scripts/install_node_deps.py to install eslint") |
| + eslint_errors_found = True |
| return eslint_errors_found |
| if files_list is None: |
| @@ -87,7 +67,9 @@ def js_lint(files_list=None): |
| eslintconfig_path = path.join(devtools_path, "front_end/.eslintrc.js") |
| eslintignore_path = path.join(devtools_path, "front_end/.eslintignore") |
| + (node_path, _) = install_node_deps.resolve_node_paths() |
| exec_command = [ |
| + node_path, |
| eslint_path, |
| "--config", to_platform_path_exact(eslintconfig_path), |
| "--ignore-path", to_platform_path_exact(eslintignore_path), |
| @@ -109,5 +91,3 @@ errors_found = js_lint(files_to_lint) |
| if errors_found: |
| print("ERRORS DETECTED") |
| sys.exit(1) |
| -else: |
| - print("OK") |