Chromium Code Reviews| Index: third_party/closure_linter/closure_linter/fixjsstyle.py |
| diff --git a/third_party/closure_linter/closure_linter/fixjsstyle.py b/third_party/closure_linter/closure_linter/fixjsstyle.py |
| index 1b5905b131c7e57b42666224c63c222d6ae0f7f4..2d65e0398fdcc6d2df189bb89bdd1f22af180056 100755 |
| --- a/third_party/closure_linter/closure_linter/fixjsstyle.py |
| +++ b/third_party/closure_linter/closure_linter/fixjsstyle.py |
| @@ -18,6 +18,7 @@ |
| __author__ = 'robbyw@google.com (Robert Walker)' |
| +import StringIO |
|
Dan Beam
2016/09/08 21:39:07
this is probably fine
|
| import sys |
| import gflags as flags |
| @@ -30,6 +31,7 @@ FLAGS = flags.FLAGS |
| flags.DEFINE_list('additional_extensions', None, 'List of additional file ' |
| 'extensions (not js) that should be treated as ' |
| 'JavaScript files.') |
| +flags.DEFINE_boolean('dry_run', False, 'Do not modify the file, only print it.') |
| def main(argv=None): |
| @@ -47,11 +49,17 @@ def main(argv=None): |
| files = fileflags.GetFileList(argv, 'JavaScript', suffixes) |
| - fixer = error_fixer.ErrorFixer() |
| + output_buffer = None |
| + if FLAGS.dry_run: |
| + output_buffer = StringIO.StringIO() |
| + |
| + fixer = error_fixer.ErrorFixer(output_buffer) |
| # Check the list of files. |
| for filename in files: |
| runner.Run(filename, fixer) |
| + if FLAGS.dry_run: |
| + print output_buffer.getvalue() |
| if __name__ == '__main__': |