From 750480e30c80027bb57295f21cbfef4aa84e8f3d Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Tue, 9 Jun 2026 18:34:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B7=A5=E4=BD=9C=E5=8C=BA=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E7=A7=BB=E5=88=B0=E6=B5=81=E7=A8=8B=E6=9C=80=E5=BC=80?= =?UTF-8?q?=E5=A7=8B=EF=BC=8C=E9=81=BF=E5=85=8D=E5=86=99=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E5=90=8E=E6=89=8D=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/release.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/release.ts b/scripts/release.ts index 2625546..fc7916e 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -94,18 +94,18 @@ async function runTests(): Promise { } } -async function stepGitCommitTag(version: string): Promise { - // 检查工作区状态 - const statusProc = Bun.spawn(["git", "status", "--porcelain"], { +async function checkWorkingTree(): Promise { + 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 { 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 { + await checkWorkingTree(); + const newVersion = await stepBumpVersion(); console.log(`目标版本: ${newVersion}`);