Skip to content

Commit 2b51d54

Browse files
authored
fix(config): prevent undefined overrides from overwriting defaults (#118)
1 parent 5702ec8 commit 2b51d54

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

src/config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,17 @@ export async function loadBumpConfig(
4040
cwd,
4141
})
4242

43+
// Omit undefined overrides so they don't overwrite defaults (undefined = "use default")
44+
const definedOverrides = overrides
45+
? Object.fromEntries(
46+
Object.entries(overrides).filter(([, v]) => v !== undefined),
47+
) as Partial<VersionBumpOptions>
48+
: {}
49+
4350
return {
51+
...bumpConfigDefaults,
4452
...config,
45-
...overrides,
53+
...definedOverrides,
4654
}
4755
}
4856

test/parse-args.test.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, expect, it } from 'vitest'
2-
import { loadCliArgs } from '../src/cli/parse-args'
2+
import { loadCliArgs, parseArgs } from '../src/cli/parse-args'
3+
import { loadBumpConfig } from '../src/config'
34

45
const defaultArgs = ['node', 'bumpp']
56

@@ -72,3 +73,27 @@ describe('loadCliArgs', async () => {
7273
expect(result.args.configFilePath).toBe('test/fixtures/build.config.ts')
7374
})
7475
})
76+
77+
describe('loadBumpConfig (confirm regression fix)', () => {
78+
it('preserves default confirm when overrides pass confirm: undefined', async () => {
79+
const config = await loadBumpConfig({ confirm: undefined })
80+
expect(config.confirm).toBe(true)
81+
})
82+
83+
it('preserves default noGitCheck when overrides pass noGitCheck: undefined', async () => {
84+
const config = await loadBumpConfig({ noGitCheck: undefined })
85+
expect(config.noGitCheck).toBe(true)
86+
})
87+
88+
it('applies explicit confirm: false when --yes would be passed', async () => {
89+
const config = await loadBumpConfig({ confirm: false })
90+
expect(config.confirm).toBe(false)
91+
})
92+
})
93+
94+
describe('parseArgs (confirm regression fix)', () => {
95+
it('has confirm: true when run without --yes (prompts before bump)', async () => {
96+
const { options } = await parseArgs()
97+
expect(options.confirm).toBe(true)
98+
})
99+
})

0 commit comments

Comments
 (0)