Skip to content

Commit ae82ed4

Browse files
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 <[email protected]>
1 parent cbd5907 commit ae82ed4

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

dist/index.js

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,16 @@ async function* lineOfFileGenerator({
171171
input: fileStream,
172172
crlfDelay: Infinity
173173
})
174-
for await (const line of rl) {
174+
for await (let line of rl) {
175175
if (!line.startsWith('#') && line !== '') {
176176
if (excludedFiles) {
177-
if (line.startsWith('!')) {
178-
yield line
179-
} else {
180-
yield `!${line}`
177+
line = line.startsWith('!') ? line : `!${line}`
178+
if (line.endsWith(path.sep)) {
179+
line = `${line}**`
181180
}
181+
yield line
182182
} else {
183+
line = line.endsWith(path.sep) ? `${line}**` : line
183184
yield line
184185
}
185186
}
@@ -998,6 +999,7 @@ export const getFilePatterns = async ({
998999
if (inputs.files) {
9991000
const filesPatterns = inputs.files
10001001
.split(inputs.filesSeparator)
1002+
.map(p => (p.endsWith(path.sep) ? `${p}**` : p))
10011003
.filter(Boolean)
10021004

10031005
cleanedFilePatterns.push(...filesPatterns)
@@ -1029,8 +1031,9 @@ export const getFilePatterns = async ({
10291031
.split(inputs.filesIgnoreSeparator)
10301032
.filter(Boolean)
10311033
.map(p => {
1032-
if (!p.startsWith('!')) {
1033-
p = `!${p}`
1034+
p = p.startsWith('!') ? p : `!${p}`
1035+
if (p.endsWith(path.sep)) {
1036+
p = `${p}**`
10341037
}
10351038
return p
10361039
})

0 commit comments

Comments
 (0)