blob: 7d60203bce5671d631869e4895060d7c0c0f5ad7 [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001# 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
7def 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)
11 results += CheckNpmAudit(input_api, output_api)
12 return results
13
14
15def CheckChangeOnUpload(input_api, output_api):
16 return CheckChange(input_api, output_api)
17
18
19def CheckChangeOnCommit(input_api, output_api):
20 return CheckChange(input_api, output_api)
21
22
23def CheckNpmAudit(input_api, output_api): # pragma: no cover
24 file_filter = lambda f: f.LocalPath().endswith('.js')
25 affected_js_files = input_api.AffectedFiles(
26 include_deletes=False, file_filter=file_filter)
27 if not affected_js_files:
28 return []
29
30 import imp
31 appengine_path = input_api.os_path.dirname(input_api.PresubmitLocalPath())
32 js_checker_path = input_api.os_path.join(appengine_path, 'js_checker.py')
33 js_checker = imp.load_source('JSChecker', js_checker_path)
34
35 return js_checker.JSChecker(input_api, output_api).RunAuditCheck()