Skip to content

Commit

Permalink
Merge pull request #472 from spalladino/fix/cli-command-with-multiple…
Browse files Browse the repository at this point in the history
…-plugins

fix: CLI command skips unrelated plugins
  • Loading branch information
tgreyuk authored Sep 25, 2023
2 parents 836aa80 + 643b14c commit 39b60ee
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/docusaurus-plugin-typedoc/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import { PluginOptions } from './types';
// store list of plugin ids when running multiple instances
const apps: string[] = [];

const PLUGIN_NAME = 'docusaurus-plugin-typedoc';

export default function pluginDocusaurus(
context: LoadContext,
opts: Partial<PluginOptions>,
) {
return {
name: 'docusaurus-plugin-typedoc',
name: PLUGIN_NAME,
async loadContent() {
if (opts.id && !apps.includes(opts.id)) {
apps.push(opts.id);
Expand All @@ -25,12 +27,12 @@ export default function pluginDocusaurus(
cli
.command('generate-typedoc')
.description(
'(docusaurus-plugin-typedoc) Generate TypeDoc docs independently of the Docusaurus build process.',
`(${PLUGIN_NAME}) Generate TypeDoc docs independently of the Docusaurus build process.`,
)
.action(async () => {
context.siteConfig?.plugins.forEach((pluginConfig) => {
// Check PluginConfig is typed to [string, PluginOptions]
if (pluginConfig && typeof pluginConfig[1] === 'object') {
if (pluginConfig && typeof pluginConfig[1] === 'object' && pluginConfig[0] === PLUGIN_NAME) {
generateTypedoc(context, pluginConfig[1]);
}
});
Expand Down

0 comments on commit 39b60ee

Please sign in to comment.