MCPcopy
hub / github.com/ampproject/amphtml / runCheck

Function runCheck

build-system/tasks/check-invalid-whitespaces.js:16–29  ·  view source on GitHub ↗

* Runs the check on the given list of files and prints results. Uses the * built-in functionality of `git diff --check` to generate results. Checks * entire files by comparing their contents against an empty commit. * * @param {Array } filesToCheck

(filesToCheck)

Source from the content-addressed store, hash-verified

14 * @param {Array<string>} filesToCheck
15 */
16function runCheck(filesToCheck) {
17 logLocalDev(green('Checking files for invalid whitespaces...'));
18 const fileList = filesToCheck.join(' ');
19 const emptyCommit = getStdout('git hash-object -t tree /dev/null').trim();
20 const checkFileCmd = `git -c color.ui=always diff ${emptyCommit} --check ${fileList}`;
21 const result = getStdout(checkFileCmd).trim();
22 if (result.length) {
23 logWithoutTimestamp(result);
24 log(red('ERROR:'), 'Please fix the files listed above.');
25 process.exitCode = 1;
26 } else {
27 log(green('SUCCESS:'), 'No invalid whitespaces found.');
28 }
29}
30
31/**
32 * Checks multiple kinds of files for invalid whitespaces.

Callers 1

checkInvalidWhitespacesFunction · 0.70

Calls 6

logLocalDevFunction · 0.85
greenFunction · 0.85
getStdoutFunction · 0.85
logWithoutTimestampFunction · 0.85
redFunction · 0.85
logFunction · 0.50

Tested by

no test coverage detected