From 1fd0471a149dde9aa378596be92a510b1767825d Mon Sep 17 00:00:00 2001 From: Cloyd Lau <253055734@qq.com> Date: Sat, 16 Sep 2023 00:21:33 +0800 Subject: [PATCH] workflow: should abort when lint, unit test or build failed --- scripts/release.mts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/release.mts b/scripts/release.mts index 942da38..7471306 100644 --- a/scripts/release.mts +++ b/scripts/release.mts @@ -12,13 +12,19 @@ async function release() { spawn.sync('pnpm', ['up'], { stdio: 'inherit' }) console.log(cyan('Linting staged...')) - spawn.sync('npx', ['lint-staged'], { stdio: 'inherit' }) + if (spawn.sync('npx', ['lint-staged'], { stdio: 'inherit' }).status === 1) { + return + } console.log(cyan('Unit testing...')) - spawn.sync('pnpm', ['test-unit'], { stdio: 'inherit' }) + if (spawn.sync('pnpm', ['test-unit'], { stdio: 'inherit' }).status === 1) { + return + } console.log(cyan('Building...')) - spawn.sync('pnpm', ['build'], { stdio: 'inherit' }) + if (spawn.sync('pnpm', ['build'], { stdio: 'inherit' }).status === 1) { + return + } console.log(cyan('Packing...')) spawn.sync('npm', ['pack'], { stdio: 'inherit' }) @@ -82,8 +88,7 @@ async function release() { fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2)) console.log(cyan('Publishing...')) - const { status } = spawn.sync('npm', ['publish', '--registry=https://registry.npmjs.org'], { stdio: 'inherit' }) - if (status === 1) { + if (spawn.sync('npm', ['publish', '--registry=https://registry.npmjs.org'], { stdio: 'inherit' }).status === 1) { // 恢复版本号 pkg.version = currentVersion fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2))