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 | #!/usr/bin/env node
'use strict'
/**
* stop-previewer
*
* Tears down the detached previewer server started by start-previewer, using
* the pid recorded in .workflow/<release>/previewer.pid. Kills the whole
* process group (next dev spawns children) and removes the pid file.
*
* Usage:
* node .claude/skills/icons-release/scripts/stop-previewer.js --release R264
*
* Output: { success, step, data: { stopped, pid } }
*/
const fs = require('fs')
const path = require('path')
const { succeed, failWith, run, log } = require('./lib/output')
const { parseArgs } = require('./lib/args')
const { parseRelease, WORKFLOW_ROOT } = require('./lib/workset')
const STEP = 'stop-previewer'
function kill(pid) {
// Negative pid targets the whole group (start-previewer is detached, so the
// child is its own group leader). Fall back to the bare pid.
try {
process.kill(-pid)
return true
} catch (_) {
try {
process.kill(pid)
return true
} catch (_) {
return false
}
}
}
function main() {
const args = parseArgs(process.argv.slice(2))
if (!args.release) failWith(STEP, 'missingArg', '--release is required (e.g. --release R264)')
const { release } = parseRelease(args.release)
const pidFile = path.join(WORKFLOW_ROOT, release, 'previewer.pid')
if (!fs.existsSync(pidFile)) {
// Nothing recorded — treat as already stopped (idempotent teardown).
succeed(STEP, { stopped: false, pid: null })
return
}
const { pid } = JSON.parse(fs.readFileSync(pidFile, 'utf8'))
log(`> stopping previewer pid ${pid}`)
const stopped = kill(pid)
fs.rmSync(pidFile, { force: true })
succeed(STEP, { stopped, pid })
}
run(STEP, main)
|