Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import argparse | 6 import argparse |
| 7 import os | 7 import os |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 if path not in sys.path: | 27 if path not in sys.path: |
| 28 sys.path.insert(0, path) | 28 sys.path.insert(0, path) |
| 29 | 29 |
| 30 | 30 |
| 31 if __name__ == '__main__': | 31 if __name__ == '__main__': |
| 32 _AddToPathIfNeeded(_ESLINT_PATH) | 32 _AddToPathIfNeeded(_ESLINT_PATH) |
| 33 import eslint | 33 import eslint |
| 34 | 34 |
| 35 parser = argparse.ArgumentParser( | 35 parser = argparse.ArgumentParser( |
| 36 description='Wrapper script to run eslint on Catapult code') | 36 description='Wrapper script to run eslint on Catapult code') |
| 37 parser.add_argument('--files', '-f', default=None, nargs='+', metavar='FILE', | 37 parser.add_argument('--files', '-f', default=None, nargs='+', metavar='FILE', |
|
charliea (OOO until 10-5)
2016/11/28 21:54:21
(Here and wherever makes sense) can you change "fi
eakuefner
2016/11/28 22:27:50
Done.
| |
| 38 help='List of files to lint') | 38 help='List of files/dirs to lint') |
| 39 parser.add_argument('--all', default=None, action='store_true', | 39 parser.add_argument('--all', default=None, action='store_true', |
| 40 help='Runs eslint on all applicable Catapult code') | 40 help='Runs eslint on all applicable Catapult code') |
| 41 parser.add_argument('--extra-args', default=None, type=str, | 41 parser.add_argument('--extra-args', default=None, type=str, |
| 42 help='A string of extra arguments to pass to eslint') | 42 help='A string of extra arguments to pass to eslint') |
| 43 | 43 |
| 44 args = parser.parse_args(sys.argv[1:]) | 44 args = parser.parse_args(sys.argv[1:]) |
| 45 if ((args.files is not None and args.all is not None) or | 45 if ((args.files is not None and args.all is not None) or |
| 46 (args.files is None and args.all is None)): | 46 (args.files is None and args.all is None)): |
| 47 print 'Either --files or --all must be used, but not both.\n' | 47 print 'Either --files or --all must be used, but not both.\n' |
| 48 parser.print_help() | 48 parser.print_help() |
| 49 sys.exit(1) | 49 sys.exit(1) |
| 50 | 50 |
| 51 if args.all: | 51 if args.all: |
| 52 print eslint.RunEslintOnDirs( | 52 print eslint.RunEslint( |
| 53 DIRECTORIES_TO_LINT, extra_args=args.extra_args) | 53 DIRECTORIES_TO_LINT, extra_args=args.extra_args)[0] |
| 54 else: | 54 else: |
| 55 print eslint.RunEslintOnFiles(args.files, extra_args=args.extra_args) | 55 print eslint.RunEslint(args.files, extra_args=args.extra_args)[0] |
| OLD | NEW |