fix(v2): load plugin commands async to fix broken plugin CLI commands `docs:version` (#3869)

* fix(v2): load plugin commands asynchronously

https://github.com/facebook/docusaurus/blame/master/packages/docusaurus/src/commands/external.ts#L12 changed the exported method to an async function, but the CLI loader was not updated to also run async, breaking things such as `npm run docusaurus docs:version <version>`.

* chore(v2): resolve lint issue
This commit is contained in:
hackerman 2020-12-03 18:23:26 +01:00 committed by GitHub
parent 70dece09e6
commit 415a7973f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -252,12 +252,16 @@ function isInternalCommand(command) {
].includes(command);
}
if (!isInternalCommand(process.argv.slice(2)[0])) {
externalCommand(cli, path.resolve('.'));
async function run() {
if (!isInternalCommand(process.argv.slice(2)[0])) {
await externalCommand(cli, path.resolve('.'));
}
cli.parse(process.argv);
if (!process.argv.slice(2).length) {
cli.outputHelp();
}
}
cli.parse(process.argv);
if (!process.argv.slice(2).length) {
cli.outputHelp();
}
run();