Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | #!/usr/bin/env node
'use strict'
/**
* build-and-test
*
* Runs the repo build and then the test suite as a release gate. Thin,
* deterministic wrapper around the existing yarn scripts — it makes NO code
* decisions, it only reports pass/fail per step and stops at the first failure.
*
* Usage:
* node .claude/skills/icons-release/scripts/build-and-test.js
* node .claude/skills/icons-release/scripts/build-and-test.js --build-cmd "yarn build" --test-cmd "yarn test"
*
* Output:
* { success: true, step: "build-and-test", data: { steps: [...] } }
* { success: false, step: "build-and-test", error: { reason, detail }, data: { failedStep } }
*/
const { spawnSync } = require('child_process')
const { log } = require('./lib/output')
const { parseArgs } = require('./lib/args')
const STEP = 'build-and-test'
function runStep(name, command) {
log(`\n> ${name}: ${command}`)
// Route the child's stdout AND stderr to our stderr so our own stdout stays
// reserved for the single JSON envelope the orchestrator parses.
const result = spawnSync(command, { shell: true, stdio: ['ignore', 2, 2] })
return { name, command, exitCode: result.status === null ? 1 : result.status }
}
function emit(obj) {
process.stdout.write(JSON.stringify(obj, null, 2) + '\n')
}
function main() {
const args = parseArgs(process.argv.slice(2))
const steps = [
{ name: 'build', command: args['build-cmd'] || 'yarn build' },
{ name: 'test', command: args['test-cmd'] || 'yarn test' }
]
const completed = []
for (const step of steps) {
const result = runStep(step.name, step.command)
completed.push(result)
if (result.exitCode !== 0) {
emit({
success: false,
step: STEP,
error: {
reason: 'stepFailed',
detail: `"${step.command}" exited with code ${result.exitCode}`
},
data: { failedStep: step.name, steps: completed }
})
process.exit(1)
}
}
emit({ success: true, step: STEP, data: { steps: completed } })
process.exit(0)
}
main()
|