Skip to content

Commit f588753

Browse files
authored
fix: resolve the options in config file correctly (#101)
1 parent 1fdda1c commit f588753

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/cli/parse-args.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export async function parseArgs(): Promise<ParsedArgs> {
3737
push: args.push,
3838
all: args.all,
3939
noGitCheck: args.noGitCheck,
40-
confirm: !args.yes,
41-
noVerify: !args.verify,
40+
confirm: args.yes === undefined ? undefined : !args.yes,
41+
noVerify: args.verify === undefined ? undefined : !args.verify,
4242
install: args.install,
4343
files: [...(args['--'] || []), ...resultArgs],
4444
ignoreScripts: args.ignoreScripts,
@@ -102,18 +102,28 @@ export function loadCliArgs(argv = process.argv) {
102102
const rawArgs = cli.rawArgs
103103
const args = result.options
104104

105+
// TODO: To simplify the checks here, should we move the default value declaration to config.ts/bumpConfigDefaults?
105106
const COMMIT_REG = /(?:-c|--commit|--no-commit)(?:=.*|$)/
106107
const TAG_REG = /(?:-t|--tag|--no-tag)(?:=.*|$)/
108+
const YES_REG = /(?:-y|--yes)(?:=.*|$)/
109+
const NO_VERIFY_REG = /--no-verify(?:=.*|$)/
110+
const INSTALL_ARG = /--install(?:=.*|$)/
107111
const hasCommitFlag = rawArgs.some(arg => COMMIT_REG.test(arg))
108112
const hasTagFlag = rawArgs.some(arg => TAG_REG.test(arg))
113+
const hasYesFlag = rawArgs.some(arg => YES_REG.test(arg))
114+
const hasNoVerifyFlag = rawArgs.some(arg => NO_VERIFY_REG.test(arg))
115+
const hasInstallFlag = rawArgs.some(arg => INSTALL_ARG.test(arg))
109116

110-
const { tag, commit, ...rest } = args
117+
const { tag, commit, yes, ...rest } = args
111118

112119
return {
113120
args: {
114121
...rest,
115122
commit: hasCommitFlag ? commit : undefined,
116123
tag: hasTagFlag ? tag : undefined,
124+
yes: hasYesFlag ? yes : undefined,
125+
verify: hasNoVerifyFlag ? !args.verify : undefined,
126+
install: hasInstallFlag ? !args.install : undefined
117127
} as { [k: string]: any },
118128
resultArgs: result.args,
119129
}

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export async function loadBumpConfig(
3333
},
3434
cwd: configFile ? dirname(configFile) : cwd,
3535
})
36+
3637
return config!
3738
}
3839

0 commit comments

Comments
 (0)