Skip to content

Commit ee2f62f

Browse files
jdechicchisclaude
andcommitted
Fix config file boolean options being ignored
Boolean CLI options with defaults (keepComments, sortComponentsProps, split) were not being respected when set in a config file. This happened because Commander.js always sets these options to their default values, and the subsequent Object.assign would overwrite config file values with CLI defaults. The fix applies the same pattern already used for lineWidth, sort, and bundle: explicitly check for config file values before the merge, using nullish coalescing to preserve CLI-specified values when present. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent dcbcf06 commit ee2f62f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

bin/cli.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,14 @@ async function run(oaFile, options) {
9090

9191
// Merge .openapiformatrc and configOptions
9292
configOptions = Object.assign({}, defaultOptions, configOptions);
93+
// Preserve config file values for options that have CLI defaults
94+
// These must be set before Object.assign to prevent CLI defaults from overwriting config values
9395
options.lineWidth = configOptions?.lineWidth ?? options.lineWidth;
9496
options.sort = configOptions?.sort ?? options.sort;
9597
options.bundle = configOptions?.bundle ?? options.bundle;
98+
options.keepComments = configOptions?.keepComments ?? options.keepComments;
99+
options.sortComponentsProps = configOptions?.sortComponentsProps ?? options.sortComponentsProps;
100+
options.split = configOptions?.split ?? options.split;
96101

97102
// Merge configOptions and CLI options
98103
options = Object.assign({}, configOptions, options);

0 commit comments

Comments
 (0)