Skip to content

Commit

Permalink
fix: strip leading ./ from files array entries (#97)
Browse files Browse the repository at this point in the history
We currently only strip /, but folks likely will want to use ./ because
that works for exports
  • Loading branch information
wraithgar authored May 4, 2022
1 parent ce176f7 commit 9f519b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ class Walker extends IgnoreWalker {
if (excl) {
pattern = pattern.slice(excl[0].length)
}
// strip off any / from the start of the pattern. /foo => foo
pattern = pattern.replace(/^\/+/, '')
// strip off any / or ./ from the start of the pattern. /foo => foo, ./foo => foo
pattern = pattern.replace(/^\.?\/+/, '')
// an odd number of ! means a negated pattern. !!foo ==> foo
const negate = excl && excl[0].length % 2 === 1
set.push({ pattern, negate })
Expand Down
2 changes: 1 addition & 1 deletion test/package-json-files-with-slashes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const pkg = t.testdir({
'/lib/one.js',
'/lib/two.js',
'/lib/tre.js',
'/lib/for.js',
'./lib/for.js',
],
}),
lib: {
Expand Down

0 comments on commit 9f519b7

Please sign in to comment.