Skip to content

Commit ea921cb

Browse files
authored
fix(cli): fix write-heading-ids CLI when no files provided (#11763)
1 parent 3dbd395 commit ea921cb

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

packages/docusaurus/src/commands/writeHeadingIds.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,16 @@ export async function writeHeadingIds(
4747
): Promise<void> {
4848
const siteDir = await fs.realpath(siteDirParam);
4949

50-
const markdownFiles = await safeGlobby(
51-
files ?? (await getPathsToWatch(siteDir)),
52-
{
53-
expandDirectories: ['**/*.{md,mdx}'],
54-
},
55-
);
50+
const patterns = files.length ? files : await getPathsToWatch(siteDir);
51+
52+
const markdownFiles = await safeGlobby(patterns, {
53+
expandDirectories: ['**/*.{md,mdx}'],
54+
});
55+
56+
if (markdownFiles.length === 0) {
57+
logger.warn`No markdown files found in siteDir path=${siteDir} for patterns: ${patterns}`;
58+
return;
59+
}
5660

5761
const result = await Promise.all(
5862
markdownFiles.map((p) => transformMarkdownFile(p, options)),

0 commit comments

Comments
 (0)