From 2d7fef062af2018180de0e5df5d72cc2b1eb1bca Mon Sep 17 00:00:00 2001 From: Tomas Valenta Date: Fri, 13 Oct 2023 00:01:10 -0700 Subject: [PATCH] Deprecate wait in JS SDK; Add .wait() in JS SDK --- packages/js-sdk/src/session/process.ts | 18 ++++++++++++++++-- packages/js-sdk/src/session/terminal.ts | 19 +++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/packages/js-sdk/src/session/process.ts b/packages/js-sdk/src/session/process.ts index ee185f946..d04af04cb 100644 --- a/packages/js-sdk/src/session/process.ts +++ b/packages/js-sdk/src/session/process.ts @@ -93,13 +93,20 @@ export class ProcessOutput { * A process running in the environment. */ export class Process { + /** + * @deprecated use .wait() instead + */ + readonly finished: Promise + constructor( readonly processID: string, private readonly session: SessionConnection, private readonly triggerExit: () => void, - readonly finished: Promise, + finished: Promise, readonly output: ProcessOutput, - ) {} + ) { + this.finished = finished + } /** * Kills the process. @@ -113,6 +120,13 @@ export class Process { } } + /** + * Waits for the process to finish. + */ + async wait(): Promise { + return this.finished + } + /** * Sends data to the process stdin. * diff --git a/packages/js-sdk/src/session/terminal.ts b/packages/js-sdk/src/session/terminal.ts index 07f5eed92..935a3bcb5 100644 --- a/packages/js-sdk/src/session/terminal.ts +++ b/packages/js-sdk/src/session/terminal.ts @@ -17,15 +17,23 @@ export class TerminalOutput { /** * A terminal session running in the environment. + * */ export class Terminal { + /** + * @deprecated use .wait() instead + */ + readonly finished: Promise + constructor( readonly terminalID: string, private readonly session: SessionConnection, private readonly triggerExit: () => void, - readonly finished: Promise, + finished: Promise, readonly output: TerminalOutput, - ) {} + ) { + this.finished = finished + } get data() { return this.output.data @@ -44,6 +52,13 @@ export class Terminal { } } + /** + * Waits for the terminal to finish. + */ + async wait(): Promise { + return this.finished + } + /** * Sends data to the terminal standard input. *