From c75078aa7a2f3daa748d21d970f191bce65746f5 Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 8 Aug 2024 15:18:12 +0200 Subject: [PATCH] Fix calling docusaurus CLI with no command --- packages/docusaurus/bin/docusaurus.mjs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/docusaurus/bin/docusaurus.mjs b/packages/docusaurus/bin/docusaurus.mjs index 3e773b9f2929..d1cf8ad7d654 100755 --- a/packages/docusaurus/bin/docusaurus.mjs +++ b/packages/docusaurus/bin/docusaurus.mjs @@ -254,6 +254,14 @@ function isExternalCommand(command) { return !!(command && !isInternalCommand(command) && !command.startsWith('-')); } +// No command? We print the help message because Commander doesn't +// Note argv looks like this: ['../node','../docusaurus.mjs','',...rest] +if (process.argv.length < 3) { + logger.error("You haven't provided any Docusaurus CLI command."); + cli.outputHelp(); + process.exit(1); +} + // There is an unrecognized subcommand // Let plugins extend the CLI before parsing if (isExternalCommand(process.argv[2])) {