Skip to content

Commit

Permalink
fix: only run version command if target version different from projec…
Browse files Browse the repository at this point in the history
…t version
  • Loading branch information
longgui.wjb committed Apr 27, 2022
1 parent e3b1275 commit 899d610
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions packages/middleware-version/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,21 @@ const handler: Handler<IOpts, string> = opts => {
} else {
answers = await ctx.inquirer.prompt(questions);
}
const command = [`npm version ${answers.inputVersion || answers.version}`, "--allow-same-version"];
if (opts.noGitTagVersion) {
command.push("--no-git-tag-version");
}
if (opts.skitCommitHooks) {
command.push("--no-commit-hooks");
}
if (answers.preid) {
command.push(`--preid ${answers.preid}`);
const version = answers.inputVersion || answers.version;

if (version !== ctx.project.version) {
const command = [`npm version ${version}`, "--allow-same-version"];
if (opts.noGitTagVersion) {
command.push("--no-git-tag-version");
}
if (opts.skitCommitHooks) {
command.push("--no-commit-hooks");
}
if (answers.preid) {
command.push(`--preid ${answers.preid}`);
}
await ctx.utils.exec(command.join(" "));
}
await ctx.utils.exec(command.join(" "));

ctx.version = ctx.project.version;
ctx.console.warn("版本已更新为:", ctx.project.version);
Expand Down

0 comments on commit 899d610

Please sign in to comment.