Skip to content

Commit 786f5ed

Browse files
committedMar 11, 2025··
fix: don't override mode from config file
1 parent 591f483 commit 786f5ed

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed
 

‎src/cli.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,20 @@ cli
3535
.option('--include-locked, -l', 'include locked dependencies & devDependencies')
3636
.option('--timediff', 'show time difference between the current and the updated version')
3737
.action(async (mode: RangeMode | undefined, options: Partial<CheckOptions>) => {
38-
mode ||= 'default'
39-
if (!MODE_CHOICES.includes(mode)) {
40-
console.error(`Invalid mode: ${mode}. Please use one of the following: ${MODE_CHOICES.join('|')}`)
41-
process.exit(1)
38+
if (mode) {
39+
if (!MODE_CHOICES.includes(mode)) {
40+
console.error(`Invalid mode: ${mode}. Please use one of the following: ${MODE_CHOICES.join('|')}`)
41+
process.exit(1)
42+
}
43+
options.mode = mode
4244
}
45+
const resolved = await resolveConfig(options)
46+
4347
let exitCode
4448
if (options.global)
45-
exitCode = await checkGlobal(await resolveConfig({ ...options, mode } as CheckOptions))
49+
exitCode = await checkGlobal(resolved)
4650
else
47-
exitCode = await check(await resolveConfig({ ...options, mode } as CheckOptions))
51+
exitCode = await check(resolved)
4852

4953
process.exit(exitCode)
5054
})

‎src/config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ export async function resolveConfig(
5050
const config = await loader.load()
5151

5252
if (!config.sources.length)
53-
return deepmerge(defaults, options as T) as T
53+
return deepmerge(defaults, options)
5454

5555
debug(`config file found ${config.sources[0]}`)
5656
const configOptions = normalizeConfig(config.config)
5757

58-
return deepmerge(deepmerge(defaults, configOptions), options as T) as T
58+
return deepmerge(deepmerge(defaults, configOptions), options)
5959
}

0 commit comments

Comments
 (0)
Please sign in to comment.