Index: common/eslint/bin/run_eslint |
diff --git a/common/eslint/bin/run_eslint b/common/eslint/bin/run_eslint |
new file mode 100755 |
index 0000000000000000000000000000000000000000..89d38ec62cb1d9009e38dd28b358fdd3f840d9de |
--- /dev/null |
+++ b/common/eslint/bin/run_eslint |
@@ -0,0 +1,37 @@ |
+#!/usr/bin/env python |
+# 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. |
+ |
+import os |
+import sys |
+ |
+ |
+_CATAPULT_PATH = os.path.abspath( |
+ os.path.join(os.path.dirname(__file__), |
+ os.path.pardir, os.path.pardir, os.path.pardir)) |
+ |
+ |
+_ESLINT_PATH = os.path.abspath( |
+ os.path.join(os.path.dirname(__file__), os.path.pardir)) |
+ |
+ |
+DIRECTORIES_TO_LINT = [ |
+ os.path.join(_CATAPULT_PATH, 'dashboard', 'dashboard'), |
+ os.path.join(_CATAPULT_PATH, 'tracing', 'tracing') |
+] |
+ |
+ |
+def _AddToPathIfNeeded(path): |
+ if path not in sys.path: |
+ sys.path.insert(0, path) |
+ |
+ |
+if __name__ == '__main__': |
charliea (OOO until 10-5)
2016/09/23 13:06:35
Is there a good place to provide usage information
nednguyen
2016/09/23 13:16:04
Best is to use argparse & make commandline flag in
|
+ _AddToPathIfNeeded(_ESLINT_PATH) |
+ import eslint |
+ |
+ if len(sys.argv) == 1: |
+ print eslint.RunEslintOnDirs(DIRECTORIES_TO_LINT) |
+ else: |
+ print eslint.RunEslint(sys.argv[1:]) |