Commit c2388472 by chunhong.mu

fix(root): fix scripts branch naming and build-changed JSON parsing

parent 90b3136e
Showing with 14 additions and 3 deletions
import { execSync } from 'node:child_process'
import { readFileSync } from 'node:fs'
import { readFileSync, unlinkSync } from 'node:fs'
import { resolve } from 'node:path'
/**
......@@ -16,10 +16,13 @@ function main()
{
console.log('Detecting changed packages since last release...\n')
const tmpFile = resolve(process.cwd(), '.changeset-status-tmp.json')
try
{
// 获取 changeset 状态(JSON 格式)
const statusOutput = run('pnpm changeset status --output=json')
// 获取 changeset 状态(输出到临时文件)
run(`npx changeset status --output=${tmpFile}`)
const statusOutput = readFileSync(tmpFile, 'utf-8')
const status = JSON.parse(statusOutput)
if (!status.releases || status.releases.length === 0)
......@@ -57,6 +60,9 @@ function main()
}
catch (error: any)
{
// 清理临时文件
try { unlinkSync(tmpFile) } catch {}
if (error.message?.includes('No unreleased changesets found'))
{
console.log('No unreleased changesets found. Nothing to build.')
......@@ -67,6 +73,11 @@ function main()
process.exit(1)
}
}
finally
{
// 清理临时文件
try { unlinkSync(tmpFile) } catch {}
}
}
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment