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 26 matching lines...) Expand all Loading... |
37 results.extend( | 37 results.extend( |
38 input_api.canned_checks.RunUnitTests(input_api, output_api, tests)) | 38 input_api.canned_checks.RunUnitTests(input_api, output_api, tests)) |
39 | 39 |
40 import sys | 40 import sys |
41 old_path = sys.path | 41 old_path = sys.path |
42 | 42 |
43 try: | 43 try: |
44 sys.path = [resources] + old_path | 44 sys.path = [resources] + old_path |
45 from web_dev_style import css_checker, js_checker | 45 from web_dev_style import css_checker, js_checker |
46 | 46 |
47 def is_resource(f): | 47 def is_resource(maybe_resource): |
48 return f.LocalPath().endswith(('.css', '.html', '.js')) | 48 f = maybe_resource.AbsoluteLocalPath() |
| 49 return f.endswith(('.css', '.html', '.js')) and f.startswith(resources) |
49 | 50 |
50 results.extend(css_checker.CSSChecker(input_api, output_api, | 51 results.extend(css_checker.CSSChecker(input_api, output_api, |
51 file_filter=is_resource).RunChecks()) | 52 file_filter=is_resource).RunChecks()) |
52 results.extend(js_checker.JSChecker(input_api, output_api, | 53 results.extend(js_checker.JSChecker(input_api, output_api, |
53 file_filter=is_resource).RunChecks()) | 54 file_filter=is_resource).RunChecks()) |
54 finally: | 55 finally: |
55 sys.path = old_path | 56 sys.path = old_path |
56 | 57 |
57 return results | 58 return results |
OLD | NEW |