Skip to content

Commit

Permalink
feat: add support for include/exclude all nested files when a directo…
Browse files Browse the repository at this point in the history
…ry is specified and ends with a slash (#1873)

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
jackton1 and actions-user authored Jan 18, 2024
1 parent cbd5907 commit ae82ed4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
18 changes: 10 additions & 8 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
})
Expand Down

0 comments on commit ae82ed4

Please sign in to comment.