Skip to content

Commit

Permalink
fix Docusaurus CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Aug 8, 2024
1 parent 2fd5b3a commit 427c3f2
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions packages/docusaurus/bin/docusaurus.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -247,24 +247,16 @@ function isInternalCommand(command) {
);
}

// process.argv always looks like this:
// [
// '/path/to/node',
// '/path/to/docusaurus.mjs',
// '<subcommand>',
// ...subcommandArgs
// ]

// There is no subcommand
// TODO: can we use commander to handle this case?
if (process.argv.length < 3 || process.argv[2]?.startsWith('--') && process.argv[2]?!="--version") {
cli.outputHelp();
process.exit(1);
/**
* @param {string | undefined} command
*/
function isExternalCommand(command) {
return !!(command && !isInternalCommand(command) && !command.startsWith('-'));
}

// There is an unrecognized subcommand
// Let plugins extend the CLI before parsing
if (!isInternalCommand(process.argv[2])) {
if (isExternalCommand(process.argv[2])) {
// TODO: in this step, we must assume default site structure because there's
// no way to know the siteDir/config yet. Maybe the root cli should be
// responsible for parsing these arguments?
Expand Down

0 comments on commit 427c3f2

Please sign in to comment.