From a9eac471bbbcb2a645c4de2da9fe96e123ecfc27 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Thu, 9 Nov 2023 12:04:44 -0800 Subject: [PATCH] Fix test --- lib/api-event-iterator.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/api-event-iterator.js b/lib/api-event-iterator.js index 4012d6948..1b2b55bf1 100644 --- a/lib/api-event-iterator.js +++ b/lib/api-event-iterator.js @@ -1,10 +1,12 @@ -import {on} from 'node:events'; - export async function * asyncEventIteratorFromApi(api) { - for await (const [plan] of on(api, 'run')) { + // TODO: support multiple runs (watch mode) + const {value: plan} = await api.events('run').next(); + + for await (const stateChange of plan.status.events('stateChange')) { + yield stateChange; - for await (const [stateChange] of on(plan.status, 'stateChange')) { - yield stateChange; + if (stateChange.type === 'end' || stateChange.type === 'interrupt') { + break; } } }