* 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)
| 14 | * @param {Array<string>} filesToCheck |
| 15 | */ |
| 16 | function 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. |
no test coverage detected