(path, pattern)
| 492 | } |
| 493 | } |
| 494 | #addSubpatterns(path, pattern) { |
| 495 | const seen = this.#cache.add(path, pattern); |
| 496 | if (seen) { |
| 497 | return; |
| 498 | } |
| 499 | const fullpath = resolve(this.#root, path); |
| 500 | const stat = this.#cache.statSync(fullpath); |
| 501 | const last = pattern.last; |
| 502 | const isDirectory = this.#isDirectorySync(fullpath, stat, pattern); |
| 503 | const isLast = pattern.isLast(isDirectory); |
| 504 | const isFirst = pattern.isFirst(); |
| 505 | |
| 506 | if (this.#isExcluded(fullpath)) { |
| 507 | return; |
| 508 | } |
| 509 | if (isFirst && isWindows && typeof pattern.at(0) === 'string' && StringPrototypeEndsWith(pattern.at(0), ':')) { |
| 510 | // Absolute path, go to root |
| 511 | this.#addSubpattern(`${pattern.at(0)}\\`, pattern.child(new SafeSet().add(1))); |
| 512 | return; |
| 513 | } |
| 514 | if (isFirst && pattern.at(0) === '') { |
| 515 | // Absolute path, go to root |
| 516 | this.#addSubpattern('/', pattern.child(new SafeSet().add(1))); |
| 517 | return; |
| 518 | } |
| 519 | if (isFirst && pattern.at(0) === '..') { |
| 520 | // Start with .., go to parent |
| 521 | this.#addSubpattern('../', pattern.child(new SafeSet().add(1))); |
| 522 | return; |
| 523 | } |
| 524 | if (isFirst && pattern.at(0) === '.') { |
| 525 | // Start with ., proceed |
| 526 | this.#addSubpattern('.', pattern.child(new SafeSet().add(1))); |
| 527 | return; |
| 528 | } |
| 529 | |
| 530 | if (isLast && typeof pattern.at(-1) === 'string') { |
| 531 | // Add result if it exists |
| 532 | const p = pattern.at(-1); |
| 533 | const stat = this.#cache.statSync(join(fullpath, p)); |
| 534 | if (stat && (p || isDirectory)) { |
| 535 | this.#results.add(join(path, p)); |
| 536 | } |
| 537 | if (pattern.indexes.size === 1 && pattern.indexes.has(last)) { |
| 538 | return; |
| 539 | } |
| 540 | } else if (isLast && pattern.at(-1) === lazyMinimatch().GLOBSTAR && |
| 541 | (path !== '.' || pattern.at(0) === '.' || (last === 0 && stat))) { |
| 542 | // If pattern ends with **, add to results |
| 543 | // if path is ".", add it only if pattern starts with "." or pattern is exactly "**" |
| 544 | this.#results.add(path); |
| 545 | } |
| 546 | |
| 547 | if (!isDirectory || this.#isCyclicSync(fullpath, isDirectory, pattern)) { |
| 548 | return; |
| 549 | } |
| 550 | |
| 551 | const nextRealpaths = this.#nextRealpathsSync(fullpath, isDirectory, pattern); |
no test coverage detected