Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Unified Diff: common/eslint/bin/run_eslint

Issue 2361623007: Add a run_eslint wrapper script (Closed)
Patch Set: Changes based on Ned's comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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:])

Powered by Google App Engine
This is Rietveld 408576698