Skip to content

Commit 31747b8

Browse files
committed
Wait for result to be written
1 parent bc2a47e commit 31747b8

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/spec-node/devContainersSpecCLI.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,9 @@ async function provision({
285285

286286
const result = await doProvision(options, providedIdLabels);
287287
const exitCode = result.outcome === 'error' ? 1 : 0;
288-
console.log(JSON.stringify(result));
288+
await new Promise<void>((resolve, reject) => {
289+
process.stdout.write(JSON.stringify(result) + '\n', err => err ? reject(err) : resolve());
290+
});
289291
if (result.outcome === 'success') {
290292
await result.finishBackgroundTasks();
291293
}
@@ -368,7 +370,9 @@ function setUpHandler(args: SetUpArgs) {
368370
async function setUp(args: SetUpArgs) {
369371
const result = await doSetUp(args);
370372
const exitCode = result.outcome === 'error' ? 1 : 0;
371-
console.log(JSON.stringify(result));
373+
await new Promise<void>((resolve, reject) => {
374+
process.stdout.write(JSON.stringify(result) + '\n', err => err ? reject(err) : resolve());
375+
});
372376
await result.dispose();
373377
process.exit(exitCode);
374378
}
@@ -530,7 +534,9 @@ function buildHandler(args: BuildArgs) {
530534
async function build(args: BuildArgs) {
531535
const result = await doBuild(args);
532536
const exitCode = result.outcome === 'error' ? 1 : 0;
533-
console.log(JSON.stringify(result));
537+
await new Promise<void>((resolve, reject) => {
538+
process.stdout.write(JSON.stringify(result) + '\n', err => err ? reject(err) : resolve());
539+
});
534540
await result.dispose();
535541
process.exit(exitCode);
536542
}
@@ -789,7 +795,9 @@ function runUserCommandsHandler(args: RunUserCommandsArgs) {
789795
async function runUserCommands(args: RunUserCommandsArgs) {
790796
const result = await doRunUserCommands(args);
791797
const exitCode = result.outcome === 'error' ? 1 : 0;
792-
console.log(JSON.stringify(result));
798+
await new Promise<void>((resolve, reject) => {
799+
process.stdout.write(JSON.stringify(result) + '\n', err => err ? reject(err) : resolve());
800+
});
793801
await result.dispose();
794802
process.exit(exitCode);
795803
}

0 commit comments

Comments
 (0)