* Gets a list of files to be checked based on command line args and the given * file matching globs. Used by tasks like prettify, lint, check-links, etc. * Optionally takes in options for globbing and a file containing ignore rules. * * @param {!Array } globs * @param {Object=} options
(globs, options = {}, ignoreFile = undefined)
| 116 | * @return {!Array<string>} |
| 117 | */ |
| 118 | function getFilesToCheck(globs, options = {}, ignoreFile = undefined) { |
| 119 | const ignored = ignore(); |
| 120 | if (ignoreFile) { |
| 121 | const ignoreRules = fs.readFileSync(ignoreFile, 'utf8'); |
| 122 | ignored.add(ignoreRules); |
| 123 | } |
| 124 | if (argv.files) { |
| 125 | return logFiles(ignored.filter(getFilesFromArgv())); |
| 126 | } |
| 127 | if (argv.local_changes) { |
| 128 | const filesChanged = ignored.filter(getFilesChanged(globs, options)); |
| 129 | if (filesChanged.length == 0) { |
| 130 | log(green('INFO: ') + 'No files to check in this PR'); |
| 131 | return []; |
| 132 | } |
| 133 | return logFiles(filesChanged); |
| 134 | } |
| 135 | return ignored.filter(fastGlob.sync(globs, options).map(String)); |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Ensures that a target is only called with `--files` or `--local_changes` |
no test coverage detected