Skip to content

Commit c3be35a

Browse files
committed
correct ** vs ./** behavior
The previous implementation was only valid prior to minimatch preserving the leading portions before an initial **, resulting in some incorrect follows in some cases. Now that we can determine whether the ** leads the pattern, the corrected behavior is more easily implemented.
1 parent cbd84c4 commit c3be35a

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/processor.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,14 @@ export class Processor {
146146
// if it's a symlink, but we didn't get here by way of a
147147
// globstar match (meaning it's the first time THIS globstar
148148
// has traversed a symlink), then we follow it. Otherwise, stop.
149-
if (
150-
!t.isSymbolicLink() ||
151-
this.follow ||
152-
pattern.followGlobstar()
153-
) {
149+
if (this.follow || !t.isSymbolicLink()) {
154150
this.subwalks.add(t, pattern)
151+
} else if (
152+
t.isSymbolicLink() &&
153+
pattern.followGlobstar() &&
154+
rest
155+
) {
156+
this.subwalks.add(t, rest)
155157
}
156158
const rp = rest?.pattern()
157159
const rrest = rest?.rest()
@@ -219,12 +221,6 @@ export class Processor {
219221
if (!pattern.hasMore()) {
220222
this.matches.add(e, absolute, false)
221223
}
222-
// record that this globstar is following a symlink, so we
223-
// can know to stop traversing when we encounter it again
224-
// in processPatterns.
225-
if (e.isSymbolicLink()) {
226-
pattern.followGlobstar()
227-
}
228224
if (e.canReaddir()) {
229225
this.subwalks.add(e, pattern)
230226
}

0 commit comments

Comments
 (0)