Skip to content

Commit

Permalink
Smarter fix to get the help from the plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore committed Mar 5, 2025
1 parent 0ce768d commit 6df68e2
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/cli/pluginOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,23 @@ export async function registerPluginOptions(yargsInstance, plugins) {
for (const pluginName of plugins) {
try {
// Dynamically import the plugin
let { default: plugin } = await importGlobalSilent(pluginName);
let plugin = await importGlobalSilent(pluginName);
// If the plugin exports a function to get CLI options, merge them
if (plugin && typeof plugin.getCliOptions === 'function') {
const options = plugin.getCliOptions();
if (
plugin &&
plugin.default & (typeof plugin.default.getCliOptions === 'function')
) {
const options = plugin.default.getCliOptions();
yargsInstance.options(options);
} else {
try {
const { default: plugin } = await import(pluginName);
if (plugin && typeof plugin.getCliOptions === 'function') {
const options = plugin.getCliOptions();
const plugin = await import(pluginName);
if (
plugin &&
plugin.default &&
typeof plugin.default.getCliOptions === 'function'
) {
const options = plugin.default.getCliOptions();
yargsInstance.options(options);
}
} catch {
Expand Down

0 comments on commit 6df68e2

Please sign in to comment.