Chromium Code Reviews| Index: common/eslint/eslint/eslint.py |
| diff --git a/common/eslint/eslint/eslint.py b/common/eslint/eslint/eslint.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..47c58319c70da0889dad6de0c813825933c9060a |
| --- /dev/null |
| +++ b/common/eslint/eslint/eslint.py |
| @@ -0,0 +1,49 @@ |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
|
nednguyen
2016/09/23 10:17:49
Move the content of this file to __init__.py inste
charliea (OOO until 10-5)
2016/09/23 13:06:34
Done.
charliea (OOO until 10-5)
2016/09/23 13:06:34
Done.
|
| +import os |
| +import subprocess |
| +import sys |
| + |
| +import py_utils |
| +from node_runner import node_util |
| + |
| + |
| +DIRECTORIES_TO_LINT = [ |
| + os.path.join(py_utils.GetCatapultDir(), 'dashboard', 'dashboard'), |
| + os.path.join(py_utils.GetCatapultDir(), 'tracing', 'tracing') |
| +] |
| + |
| + |
| +ESLINT_CMD = [ |
| + node_util.GetNodePath(), |
| + os.path.join(node_util.GetNodeModulesPath(), 'eslint', 'bin', 'eslint.js'), |
| + '--color', |
| + '--config', |
| + os.path.join(py_utils.GetCatapultDir(), 'common', 'eslint', '.eslintrc'), |
| + '--rulesdir', |
| + os.path.join(py_utils.GetCatapultDir(), 'common', 'eslint', 'rules') |
| +] |
| + |
| + |
| +def RunEslintGlobal(): |
|
nednguyen
2016/09/23 10:17:49
Can you merge this to RunEslintOnDir(dir_path), th
charliea (OOO until 10-5)
2016/09/23 13:06:34
Done.
charliea (OOO until 10-5)
2016/09/23 13:06:34
Done.
|
| + try: |
| + find_cmd = ['find'] + DIRECTORIES_TO_LINT + ['-name', '*.html'] |
| + p1 = subprocess.Popen(find_cmd, stdout=subprocess.PIPE) |
| + output = subprocess.check_output(['xargs'] + ESLINT_CMD, stdin=p1.stdout) |
| + p1.wait() |
| + return output |
| + except subprocess.CalledProcessError as e: |
| + return e.output |
| + |
| + |
| +def RunEslint(filenames=None): |
| + if filenames is None: |
| + filenames = [] |
| + |
| + try: |
| + return subprocess.check_output(ESLINT_CMD + filenames, |
| + stderr=subprocess.STDOUT) |
| + except subprocess.CalledProcessError as e: |
| + return e.output |