Skip to content

Commit

Permalink
refactor: refactor file pattern handling in generator functions
Browse files Browse the repository at this point in the history
- Modify the logic for adding wildcard characters to both directory and non-directory file patterns in the `lineOfFileGenerator` function.
- Refactor the process of adding exclamation point prefix in ignored file patterns in the `getFilePatterns` function.
- Change and simplify the method of appending the wildcard characters to paths in the `getFilePatterns` function.
  • Loading branch information
jackton1 committed Jan 18, 2024
1 parent 1054b66 commit 23cb630
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,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 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,11 +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}${path.sep}**`
p = `${p}**`
}
return p
})
Expand Down

0 comments on commit 23cb630

Please sign in to comment.