Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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