| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Presubmit script for Chromium WebUI resources. | 5 """Presubmit script for Chromium WebUI resources. |
| 6 | 6 |
| 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 8 for more details about the presubmit API built into gcl/git cl, and see | 8 for more details about the presubmit API built into gcl/git cl, and see |
| 9 http://www.chromium.org/developers/web-development-style-guide for the rules | 9 http://www.chromium.org/developers/web-development-style-guide for the rules |
| 10 we're checking against here. | 10 we're checking against here. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 if presubmit in (f.AbsoluteLocalPath() for f in input_api.AffectedFiles()): | 29 if presubmit in (f.AbsoluteLocalPath() for f in input_api.AffectedFiles()): |
| 30 tests = [path.join(resources, 'test_presubmit.py')] | 30 tests = [path.join(resources, 'test_presubmit.py')] |
| 31 results.extend( | 31 results.extend( |
| 32 input_api.canned_checks.RunUnitTests(input_api, output_api, tests)) | 32 input_api.canned_checks.RunUnitTests(input_api, output_api, tests)) |
| 33 | 33 |
| 34 import sys | 34 import sys |
| 35 old_path = sys.path | 35 old_path = sys.path |
| 36 | 36 |
| 37 try: | 37 try: |
| 38 sys.path.insert(0, resources) | 38 sys.path.insert(0, resources) |
| 39 from web_dev_style import css_checker | 39 from web_dev_style import css_checker, js_checker |
| 40 | 40 |
| 41 # TODO(dbeam): Remove this filter eventually when ready. | 41 # TODO(dbeam): Remove this filter eventually when ready. |
| 42 def file_filter(affected_file): | 42 def file_filter(affected_file): |
| 43 dirs = (path.join(resources, 'ntp4'), path.join(resources, 'options2')) | 43 dirs = (path.join(resources, 'ntp4'), path.join(resources, 'options2')) |
| 44 f = affected_file.AbsoluteLocalPath() | 44 f = affected_file.AbsoluteLocalPath() |
| 45 return (f.startswith(dirs) and f.endswith(('.css', '.html', '.js'))) | 45 return (f.startswith(dirs) and f.endswith(('.css', '.html', '.js'))) |
| 46 | 46 |
| 47 results.extend(css_checker.CSSChecker(input_api, output_api, | 47 results.extend(css_checker.CSSChecker(input_api, output_api, |
| 48 file_filter=file_filter).RunChecks()) | 48 file_filter=file_filter).RunChecks()) |
| 49 results.extend(js_checker.JSChecker(input_api, output_api, |
| 50 file_filter=file_filter).RunChecks()) |
| 49 finally: | 51 finally: |
| 50 sys.path = old_path | 52 sys.path = old_path |
| 51 | 53 |
| 52 return results | 54 return results |
| OLD | NEW |