feat: add support for include/exclude all nested files when a directory is specified and ends with a slash (#1873)

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Tonye Jack 2024-01-17 21:57:33 -07:00 committed by GitHub
parent cbd59070e8
commit ae82ed4ae0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 16 deletions

18
dist/index.js generated vendored
View File

@ -2105,17 +2105,17 @@ function lineOfFileGenerator({ filePath, excludedFiles }) {
for (var _d = true, rl_1 = __asyncValues(rl), rl_1_1; rl_1_1 = yield __await(rl_1.next()), _a = rl_1_1.done, !_a; _d = true) {
_c = rl_1_1.value;
_d = false;
const line = _c;
let line = _c;
if (!line.startsWith('#') && line !== '') {
if (excludedFiles) {
if (line.startsWith('!')) {
yield yield __await(line);
}
else {
yield yield __await(`!${line}`);
line = line.startsWith('!') ? line : `!${line}`;
if (line.endsWith(path.sep)) {
line = `${line}**`;
}
yield yield __await(line);
}
else {
line = line.endsWith(path.sep) ? `${line}**` : line;
yield yield __await(line);
}
}
@ -2639,6 +2639,7 @@ const getFilePatterns = ({ inputs, workingDirectory }) => __awaiter(void 0, void
if (inputs.files) {
const filesPatterns = inputs.files
.split(inputs.filesSeparator)
.map(p => (p.endsWith(path.sep) ? `${p}**` : p))
.filter(Boolean);
cleanedFilePatterns.push(...filesPatterns);
core.debug(`files patterns: ${filesPatterns.join('\n')}`);
@ -2660,8 +2661,9 @@ const getFilePatterns = ({ inputs, workingDirectory }) => __awaiter(void 0, void
.split(inputs.filesIgnoreSeparator)
.filter(Boolean)
.map(p => {
if (!p.startsWith('!')) {
p = `!${p}`;
p = p.startsWith('!') ? p : `!${p}`;
if (p.endsWith(path.sep)) {
p = `${p}**`;
}
return p;
});

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -171,15 +171,16 @@ async function* lineOfFileGenerator({
input: fileStream,
crlfDelay: Infinity
})
for await (const line of rl) {
for await (let line of rl) {
if (!line.startsWith('#') && line !== '') {
if (excludedFiles) {
if (line.startsWith('!')) {
yield line
} else {
yield `!${line}`
line = line.startsWith('!') ? line : `!${line}`
if (line.endsWith(path.sep)) {
line = `${line}**`
}
yield line
} else {
line = line.endsWith(path.sep) ? `${line}**` : line
yield line
}
}
@ -998,6 +999,7 @@ export const getFilePatterns = async ({
if (inputs.files) {
const filesPatterns = inputs.files
.split(inputs.filesSeparator)
.map(p => (p.endsWith(path.sep) ? `${p}**` : p))
.filter(Boolean)
cleanedFilePatterns.push(...filesPatterns)
@ -1029,8 +1031,9 @@ export const getFilePatterns = async ({
.split(inputs.filesIgnoreSeparator)
.filter(Boolean)
.map(p => {
if (!p.startsWith('!')) {
p = `!${p}`
p = p.startsWith('!') ? p : `!${p}`
if (p.endsWith(path.sep)) {
p = `${p}**`
}
return p
})