Path: blob/main/extensions/copilot/test/base/stdout.ts
13389 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/4/**5* Drains stdout and stderr, then exits the process6* @param exitCode The process exit code7*/8export async function drainStdoutAndExit(exitCode: number): Promise<never> {9await Promise.all([drainStream(process.stdout), drainStream(process.stderr)]);10process.exit(exitCode);11}1213/**14* Drains a writable stream15* @param stream The stream to drain16*/17function drainStream(stream: NodeJS.WriteStream): Promise<void> {18const ok = stream.write('');19if (!ok) {20return new Promise(resolve => {21stream.once('drain', resolve);22});23}24return Promise.resolve();25}262728