Skip to content

Commit 9f519b7

Browse files
authored
fix: strip leading ./ from files array entries (#97)
We currently only strip /, but folks likely will want to use ./ because that works for exports
1 parent ce176f7 commit 9f519b7

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ class Walker extends IgnoreWalker {
242242
if (excl) {
243243
pattern = pattern.slice(excl[0].length)
244244
}
245-
// strip off any / from the start of the pattern. /foo => foo
246-
pattern = pattern.replace(/^\/+/, '')
245+
// strip off any / or ./ from the start of the pattern. /foo => foo, ./foo => foo
246+
pattern = pattern.replace(/^\.?\/+/, '')
247247
// an odd number of ! means a negated pattern. !!foo ==> foo
248248
const negate = excl && excl[0].length % 2 === 1
249249
set.push({ pattern, negate })

test/package-json-files-with-slashes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const pkg = t.testdir({
1313
'/lib/one.js',
1414
'/lib/two.js',
1515
'/lib/tre.js',
16-
'/lib/for.js',
16+
'./lib/for.js',
1717
],
1818
}),
1919
lib: {

0 commit comments

Comments
 (0)