Smarter fix to get the help from the plugin (#4465)
This commit is contained in:
parent
0ce768d2a4
commit
e33e635f89
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue