diff --git a/src/cli/expand-patterns.js b/src/cli/expand-patterns.js index 9362a54fabbc..65ca148de9be 100644 --- a/src/cli/expand-patterns.js +++ b/src/cli/expand-patterns.js @@ -128,20 +128,19 @@ async function* expandPatternsInternal(context) { } function getSupportedFilesGlob() { - if (!supportedFilesGlob) { - const extensions = context.languages.flatMap( - (lang) => lang.extensions || [], - ); - const filenames = context.languages.flatMap( - (lang) => lang.filenames || [], - ); - supportedFilesGlob = [ - ...extensions.map((ext) => "*" + (ext[0] === "." ? ext : "." + ext)), - ...filenames, - ]; - } + supportedFilesGlob ??= [...getSupportedFilesGlobWithoutCache()]; return supportedFilesGlob; } + + function* getSupportedFilesGlobWithoutCache() { + for (const { extensions = [], filenames = [] } of context.languages) { + yield* filenames; + + for (const extension of extensions) { + yield `*${extension.startsWith(".") ? extension : `.${extension}`}`; + } + } + } } const errorMessages = {