The install overlay had no way to stop a running install — the runner already supported an abortSignal, but nothing drove it. Wire it end to end: - main.cjs holds an AbortController for the active runBootstrap and aborts it on a new hermes:bootstrap:cancel IPC and on app quit, so quitting/cancelling mid-install actually kills install.sh/ps1 instead of orphaning it. - runBootstrap bails before spawning anything if the signal is already aborted. - Install overlay gains a "Cancel install" button while a bootstrap is active; a cancel surfaces the recovery overlay (retry/repair). Test: electron/bootstrap-runner.test.cjs asserts the already-aborted early return (no spawn) via `node --test`.
28 lines
856 B
JavaScript
28 lines
856 B
JavaScript
const assert = require('node:assert/strict')
|
|
const test = require('node:test')
|
|
|
|
const { runBootstrap } = require('./bootstrap-runner.cjs')
|
|
|
|
test('runBootstrap bails immediately when the signal is already aborted', async () => {
|
|
const controller = new AbortController()
|
|
controller.abort()
|
|
|
|
const events = []
|
|
const result = await runBootstrap({
|
|
installStamp: null,
|
|
activeRoot: '/tmp/hermes-runner-test',
|
|
sourceRepoRoot: null,
|
|
hermesHome: '/tmp/hermes-runner-test',
|
|
logRoot: '/tmp/hermes-runner-test',
|
|
onEvent: ev => events.push(ev),
|
|
abortSignal: controller.signal
|
|
})
|
|
|
|
// Cancelled before any install script is spawned.
|
|
assert.deepEqual(result, { ok: false, cancelled: true })
|
|
assert.ok(
|
|
events.some(ev => ev.type === 'failed' && /cancelled/i.test(ev.error)),
|
|
'should emit a cancelled failure event'
|
|
)
|
|
})
|