mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
fa6e23f414
Closes #2299
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
const minimatch = require('minimatch');
|
|
|
|
module.exports = {
|
|
getIncludedFiles,
|
|
filterIgnoredFiles,
|
|
getMatchingFiles,
|
|
};
|
|
|
|
function getIncludedFiles(fileList, includePaths) {
|
|
if (!(includePaths && includePaths.length)) {
|
|
return fileList;
|
|
}
|
|
return fileList.filter(file =>
|
|
includePaths.some(
|
|
includePath => file === includePath || minimatch(file, includePath)
|
|
)
|
|
);
|
|
}
|
|
|
|
function filterIgnoredFiles(fileList, ignorePaths) {
|
|
if (!(ignorePaths && ignorePaths.length)) {
|
|
return fileList;
|
|
}
|
|
return fileList.filter(
|
|
file =>
|
|
!ignorePaths.some(
|
|
ignorePath => file.includes(ignorePath) || minimatch(file, ignorePath)
|
|
)
|
|
);
|
|
}
|
|
|
|
function getMatchingFiles(fileList, manager, fileMatch) {
|
|
let matchedFiles = [];
|
|
for (const match of fileMatch) {
|
|
logger.debug(`Using file match: ${match} for manager ${manager}`);
|
|
matchedFiles = matchedFiles.concat(
|
|
fileList.filter(file => file.match(new RegExp(match)))
|
|
);
|
|
}
|
|
// filter out duplicates
|
|
matchedFiles = matchedFiles.filter(
|
|
(item, pos) => matchedFiles.indexOf(item) === pos
|
|
);
|
|
return matchedFiles;
|
|
}
|