| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 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 """Runs Closure compiler on JavaScript files to check for errors and produce | 6 """Runs Closure compiler on JavaScript files to check for errors and produce |
| 7 minified output.""" | 7 minified output.""" |
| 8 | 8 |
| 9 import argparse | 9 import argparse |
| 10 import os | 10 import os |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 out_file: A file where the compiled output is written to. | 199 out_file: A file where the compiled output is written to. |
| 200 runner_args: Arguments passed to runner.jar. | 200 runner_args: Arguments passed to runner.jar. |
| 201 closure_args: Arguments passed directly to the Closure compiler. | 201 closure_args: Arguments passed directly to the Closure compiler. |
| 202 custom_sources: Whether |sources| was customized by the target (e.g. not | 202 custom_sources: Whether |sources| was customized by the target (e.g. not |
| 203 in GYP dependency order). | 203 in GYP dependency order). |
| 204 | 204 |
| 205 Returns: | 205 Returns: |
| 206 (found_errors, stderr) A boolean indicating whether errors were found and | 206 (found_errors, stderr) A boolean indicating whether errors were found and |
| 207 the raw Closure compiler stderr (as a string). | 207 the raw Closure compiler stderr (as a string). |
| 208 """ | 208 """ |
| 209 is_extern = lambda f: 'extern' in f | 209 is_extern = lambda f: 'externs' in f |
| 210 externs_and_deps = [self._POLYMER_EXTERNS] | 210 externs_and_deps = [self._POLYMER_EXTERNS] |
| 211 | 211 |
| 212 if custom_sources: | 212 if custom_sources: |
| 213 externs_and_deps += sources | 213 externs_and_deps += sources |
| 214 else: | 214 else: |
| 215 self._target = sources[0] | 215 self._target = sources[0] |
| 216 externs_and_deps += sources[1:] | 216 externs_and_deps += sources[1:] |
| 217 | 217 |
| 218 externs = filter(is_extern, externs_and_deps) | 218 externs = filter(is_extern, externs_and_deps) |
| 219 deps = filter(lambda f: not is_extern(f), externs_and_deps) | 219 deps = filter(lambda f: not is_extern(f), externs_and_deps) |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 | 322 |
| 323 found_errors, stderr = checker.check(opts.sources, out_file=opts.out_file, | 323 found_errors, stderr = checker.check(opts.sources, out_file=opts.out_file, |
| 324 closure_args=opts.closure_args, | 324 closure_args=opts.closure_args, |
| 325 runner_args=opts.runner_args, | 325 runner_args=opts.runner_args, |
| 326 custom_sources=opts.custom_sources) | 326 custom_sources=opts.custom_sources) |
| 327 | 327 |
| 328 if found_errors: | 328 if found_errors: |
| 329 if opts.custom_sources: | 329 if opts.custom_sources: |
| 330 print stderr | 330 print stderr |
| 331 sys.exit(1) | 331 sys.exit(1) |
| OLD | NEW |