MCPcopy Index your code
hub / github.com/ampproject/amphtml / getFilesToCheck

Function getFilesToCheck

build-system/common/utils.js:118–136  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

116 * @return {!Array<string>}
117 */
118function 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`

Callers 6

validateHtmlFixturesFunction · 0.85
lintFunction · 0.85
checkOwnersFunction · 0.85
checkLinksFunction · 0.85
checkInvalidWhitespacesFunction · 0.85
prettifyFunction · 0.85

Calls 8

logFilesFunction · 0.85
getFilesFromArgvFunction · 0.85
getFilesChangedFunction · 0.85
greenFunction · 0.85
syncMethod · 0.80
logFunction · 0.70
addMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected