Skip to content

Commit 941c6b3

Browse files
authored
Minor refactor to getSupportedFilesGlob (#15319)
1 parent f6c9e9b commit 941c6b3

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

src/cli/expand-patterns.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,19 @@ async function* expandPatternsInternal(context) {
128128
}
129129

130130
function getSupportedFilesGlob() {
131-
if (!supportedFilesGlob) {
132-
const extensions = context.languages.flatMap(
133-
(lang) => lang.extensions || [],
134-
);
135-
const filenames = context.languages.flatMap(
136-
(lang) => lang.filenames || [],
137-
);
138-
supportedFilesGlob = [
139-
...extensions.map((ext) => "*" + (ext[0] === "." ? ext : "." + ext)),
140-
...filenames,
141-
];
142-
}
131+
supportedFilesGlob ??= [...getSupportedFilesGlobWithoutCache()];
143132
return supportedFilesGlob;
144133
}
134+
135+
function* getSupportedFilesGlobWithoutCache() {
136+
for (const { extensions = [], filenames = [] } of context.languages) {
137+
yield* filenames;
138+
139+
for (const extension of extensions) {
140+
yield `*${extension.startsWith(".") ? extension : `.${extension}`}`;
141+
}
142+
}
143+
}
145144
}
146145

147146
const errorMessages = {

0 commit comments

Comments
 (0)