fix: 工作区检查移到流程最开始,避免写版本号后才报错
This commit is contained in:
@@ -94,18 +94,18 @@ async function runTests(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
async function stepGitCommitTag(version: string): Promise<void> {
|
||||
// 检查工作区状态
|
||||
const statusProc = Bun.spawn(["git", "status", "--porcelain"], {
|
||||
async function checkWorkingTree(): Promise<void> {
|
||||
const proc = Bun.spawn(["git", "status", "--porcelain"], {
|
||||
stdio: ["inherit", "pipe", "inherit"],
|
||||
});
|
||||
const statusOutput = await new Response(statusProc.stdout).text();
|
||||
const statusLines = statusOutput.trim().split("\n").filter(Boolean);
|
||||
const nonPkgChanges = statusLines.filter((line) => !/^[?MADRCU ]{2} package\.json$/.test(line));
|
||||
if (nonPkgChanges.length > 0) {
|
||||
throw new Error("工作区有其他未提交变更,请先清理后再运行 release");
|
||||
const output = await new Response(proc.stdout).text();
|
||||
const lines = output.trim().split("\n").filter(Boolean);
|
||||
if (lines.length > 0) {
|
||||
throw new Error("工作区有未提交变更,请先提交或清理后再运行 release");
|
||||
}
|
||||
}
|
||||
|
||||
async function stepGitCommitTag(version: string): Promise<void> {
|
||||
console.log("\n准备提交:");
|
||||
console.log(` git add package.json`);
|
||||
console.log(` git commit -m "chore: release v${version}"`);
|
||||
@@ -185,6 +185,8 @@ function writeVersion(version: string): void {
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
await checkWorkingTree();
|
||||
|
||||
const newVersion = await stepBumpVersion();
|
||||
console.log(`目标版本: ${newVersion}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user