682
683
const resultExpression: ParsedStringPattern = function (path: string, base?: string, hasSibling?: (name: string) => boolean | Promise<boolean>) {
684
>
let name: string | undefined = undefined;
glob.ts
685
>
let resultPromises: Promise<string | null>[] | undefined = undefined;
686
>
687
>
for (let i = 0, n = parsedPatterns.length; i < n; i++) {
688
>
689
>
// Pattern matches path
690
>
const parsedPattern = (<ParsedExpressionPattern>parsedPatterns[i]);
691
>
if (parsedPattern.requiresSiblings && hasSibling) {
692
>
if (!base) {
693
base = basename(path);
694
}
696
>
if (!name) {
697
>
name = base.substring(0, base.length - extname(path).length);
698
>
}
699
>
}
700
>
701
>
const result = parsedPattern(path, base, name, hasSibling);
702
>
if (typeof result === 'string') {
703
return result; // immediately return as soon as the first expression matches
704
}
706
>
// If the result is a promise, we have to keep it for
707
>
// later processing and await the result properly.
708
>
if (isThenable(result)) {
709
if (!resultPromises) {
710
resultPromises = [];