Skip to content

Commit

Permalink
feat(create-plugin): allow feature flag cli arg overrides in both gen…
Browse files Browse the repository at this point in the history
…erate and update commands
  • Loading branch information
jackw committed Jul 2, 2024
1 parent dbba404 commit 51417fd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
35 changes: 23 additions & 12 deletions packages/create-plugin/src/utils/utils.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,28 @@ function readRCFileSync(path: string): CreatePluginConfig | undefined {

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);

return flags;
}

return flags ?? {};
const featureFlags = commandName === 'generate' ? DEFAULT_FEATURE_FLAGS : 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);

// 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);

// return flags;
// }

// return flags ?? {};
}

0 comments on commit 51417fd

Please sign in to comment.