diff --git a/packages/create-plugin/src/utils/tests/utils.config.test.ts b/packages/create-plugin/src/utils/tests/utils.config.test.ts index 50e2f8614..84d374d62 100644 --- a/packages/create-plugin/src/utils/tests/utils.config.test.ts +++ b/packages/create-plugin/src/utils/tests/utils.config.test.ts @@ -55,6 +55,7 @@ describe('getConfig', () => { describe('Command: Update', () => { beforeEach(() => { mocks.commandName = 'update'; + mocks.argv = {}; }); it('should give back the correct config when there are no config files at all', async () => { diff --git a/packages/create-plugin/src/utils/utils.config.ts b/packages/create-plugin/src/utils/utils.config.ts index eee9bd3bd..c3d67326c 100644 --- a/packages/create-plugin/src/utils/utils.config.ts +++ b/packages/create-plugin/src/utils/utils.config.ts @@ -83,19 +83,16 @@ function readRCFileSync(path: string): CreatePluginConfig | undefined { } } +// This function creates feature flags based on the defaults for generate command else flags read from config. +// In both cases it will override the flags if any cli args with the same name are passed in. function createFeatureFlags(flags?: FeatureFlags): FeatureFlags { - // For new scaffolds override any defaults with args passed in the CLI. - if (commandName === 'generate') { - const flags = Object.entries(DEFAULT_FEATURE_FLAGS).reduce((acc, [flag, value]) => { - if (argv.hasOwnProperty(flag)) { - return { ...acc, [flag]: argv[flag] }; - } else { - return { ...acc, [flag]: value }; - } - }, {} as FeatureFlags); + const featureFlags = commandName === 'generate' ? DEFAULT_FEATURE_FLAGS : flags ?? {}; - return flags; - } - - return flags ?? {}; + return Object.entries(featureFlags).reduce((acc, [flag, value]) => { + if (argv.hasOwnProperty(flag)) { + return { ...acc, [flag]: argv[flag] }; + } else { + return { ...acc, [flag]: value }; + } + }, {} as FeatureFlags); }