Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 1 | # Copyright 2020 The Chromium Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style |
| 3 | # license that can be found in the LICENSE file or at |
| 4 | # https://developers.google.com/open-source/licenses/bsd |
| 5 | |
| 6 | |
| 7 | def CheckChange(input_api, output_api): |
| 8 | results = [] |
| 9 | results += input_api.canned_checks.CheckDoNotSubmit(input_api, output_api) |
| 10 | results += input_api.canned_checks.CheckChangeHasNoTabs(input_api, output_api) |
Adrià Vilanova MartÃnez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 11 | # NPM audit presubmit disabled. See: crbug.com/monorail/10572 |
| 12 | # results += CheckNpmAudit(input_api, output_api) |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 13 | return results |
| 14 | |
| 15 | |
| 16 | def CheckChangeOnUpload(input_api, output_api): |
| 17 | return CheckChange(input_api, output_api) |
| 18 | |
| 19 | |
| 20 | def CheckChangeOnCommit(input_api, output_api): |
| 21 | return CheckChange(input_api, output_api) |
| 22 | |
| 23 | |
| 24 | def CheckNpmAudit(input_api, output_api): # pragma: no cover |
| 25 | file_filter = lambda f: f.LocalPath().endswith('.js') |
| 26 | affected_js_files = input_api.AffectedFiles( |
| 27 | include_deletes=False, file_filter=file_filter) |
| 28 | if not affected_js_files: |
| 29 | return [] |
| 30 | |
| 31 | import imp |
| 32 | appengine_path = input_api.os_path.dirname(input_api.PresubmitLocalPath()) |
| 33 | js_checker_path = input_api.os_path.join(appengine_path, 'js_checker.py') |
| 34 | js_checker = imp.load_source('JSChecker', js_checker_path) |
| 35 | |
| 36 | return js_checker.JSChecker(input_api, output_api).RunAuditCheck() |