Reimport
This commit is contained in:
54
tools/adb/systrace/catapult/common/eslint/bin/run_eslint
Normal file
54
tools/adb/systrace/catapult/common/eslint/bin/run_eslint
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/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 argparse
|
||||
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__':
|
||||
_AddToPathIfNeeded(_ESLINT_PATH)
|
||||
import eslint
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Wrapper script to run eslint on Catapult code')
|
||||
parser.add_argument('--paths', '-p', default=None, nargs='+', metavar='PATH',
|
||||
help='List of paths to lint')
|
||||
parser.add_argument('--all', default=None, action='store_true',
|
||||
help='Runs eslint on all applicable Catapult code')
|
||||
parser.add_argument('--extra-args', default=None, type=str,
|
||||
help='A string of extra arguments to pass to eslint')
|
||||
|
||||
args = parser.parse_args(sys.argv[1:])
|
||||
if ((args.paths is not None and args.all is not None) or
|
||||
(args.paths is None and args.all is None)):
|
||||
print 'Either --paths or --all must be used, but not both.\n'
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
paths = DIRECTORIES_TO_LINT if args.all else args.paths
|
||||
success, output = eslint.RunEslint(paths, extra_args=args.extra_args)
|
||||
print output
|
||||
sys.exit(not success)
|
||||
35
tools/adb/systrace/catapult/common/eslint/bin/run_tests
Normal file
35
tools/adb/systrace/catapult/common/eslint/bin/run_tests
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/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))
|
||||
|
||||
|
||||
def _RunTestsOrDie(top_level_dir):
|
||||
exit_code = run_with_typ.Run(top_level_dir, path=[_ESLINT_PATH])
|
||||
if exit_code:
|
||||
sys.exit(exit_code)
|
||||
|
||||
|
||||
def _AddToPathIfNeeded(path):
|
||||
if path not in sys.path:
|
||||
sys.path.insert(0, path)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
_AddToPathIfNeeded(_CATAPULT_PATH)
|
||||
|
||||
from catapult_build import run_with_typ
|
||||
|
||||
_RunTestsOrDie(os.path.join(_ESLINT_PATH, 'eslint'))
|
||||
Reference in New Issue
Block a user