Skip to content

Commit

Permalink
feat: add support for excluding a nested directory files using a slas…
Browse files Browse the repository at this point in the history
…h (2) (#1063)

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
jackton1 and actions-user authored Jan 18, 2024
1 parent d9dadb0 commit dc0d0cd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
15 changes: 9 additions & 6 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.

12 changes: 7 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ export async function run(): Promise<void> {

const gitignorePath = path.join(workingDirectory, '.gitignore')

let filePatterns = files.split(filesSeparator).filter(Boolean).join('\n')
let filePatterns = files
.split(filesSeparator)
.filter(Boolean)
.map(p => (p.endsWith(path.sep) ? `${p}**` : p))
.join('\n')

core.debug(`file patterns: ${filePatterns}`)

Expand All @@ -96,11 +100,9 @@ export async function run(): Promise<void> {
.split(excludedFilesSeparator)
.filter(Boolean)
.map(p => {
if (!p.startsWith('!')) {
p = `!${p}`
}
p = p.startsWith('!') ? p : `!${p}`
if (p.endsWith(path.sep)) {
p = `${p}${path.sep}**`
p = `${p}**`
}
return p
})
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ async function* lineOfFileGenerator({
if (excludedFiles) {
line = line.startsWith('!') ? line : `!${line}`
if (line.endsWith(path.sep)) {
line = `${line}${path.sep}**`
line = `${line}**`
}

yield line
} else {
line = line.endsWith(path.sep) ? `${line}**` : line
yield line
}
}
Expand Down

0 comments on commit dc0d0cd

Please sign in to comment.