From 3ee9b19c87877b30b60db673a850b71809c43dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilherme=20Ara=C3=BAjo?= Date: Fri, 14 Mar 2025 16:29:03 -0300 Subject: [PATCH] fix(loaders): missing promise --- bin/cli.mjs | 2 +- src/loaders/markdown.mjs | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bin/cli.mjs b/bin/cli.mjs index 84a7a33d..df1cbc4e 100755 --- a/bin/cli.mjs +++ b/bin/cli.mjs @@ -108,7 +108,7 @@ const linter = createLinter(lintDryRun, disableRule); const { loadFiles } = createMarkdownLoader(); const { parseApiDocs } = createMarkdownParser(); -const apiDocFiles = loadFiles(input, ignore); +const apiDocFiles = await loadFiles(input, ignore); const parsedApiDocs = await parseApiDocs(apiDocFiles); diff --git a/src/loaders/markdown.mjs b/src/loaders/markdown.mjs index ba7df02d..4c25ac9f 100644 --- a/src/loaders/markdown.mjs +++ b/src/loaders/markdown.mjs @@ -22,7 +22,7 @@ const createLoader = () => { * * @see https://code.visualstudio.com/docs/editor/glob-patterns */ - const loadFiles = (searchPath, ignorePath) => { + const loadFiles = async (searchPath, ignorePath) => { const ignoredFiles = ignorePath ? globSync(ignorePath).filter(filePath => extname(filePath) === '.md') : []; @@ -32,11 +32,13 @@ const createLoader = () => { extname(filePath) === '.md' && !ignoredFiles.includes(filePath) ); - return resolvedFiles.map(async filePath => { - const fileContents = await readFile(filePath, 'utf-8'); + return Promise.all( + resolvedFiles.map(async filePath => { + const fileContents = await readFile(filePath, 'utf-8'); - return new VFile({ path: filePath, value: fileContents }); - }); + return new VFile({ path: filePath, value: fileContents }); + }) + ); }; return { loadFiles };