From 4c43fee943cad8af8644b7feeb2b41aa1ec599fd Mon Sep 17 00:00:00 2001 From: James Ives Date: Fri, 17 May 2024 21:57:27 -0400 Subject: [PATCH] Update execute.ts --- src/execute.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/execute.ts b/src/execute.ts index db560fe99a..9a8ff97fe8 100644 --- a/src/execute.ts +++ b/src/execute.ts @@ -4,9 +4,10 @@ import buffer from 'buffer' type ExecuteOutput = { stdout: string stderr: string + exitCode: number; } -const output: ExecuteOutput = {stdout: '', stderr: ''} +const output: ExecuteOutput = {stdout: '', stderr: '', exitCode: 0} /** Wrapper around the GitHub toolkit exec command which returns the output. * Also allows you to easily toggle the current working directory. @@ -26,15 +27,22 @@ export async function execute( output.stdout = '' output.stderr = '' - await exec(cmd, [], { + output.exitCode = await exec(cmd, [], { // Silences the input unless the INPUT_DEBUG flag is set. silent, cwd, - listeners: {stdout, stderr}, + listeners: { + stdout: (data: Buffer) => { + stdout(data); + }, + stderr: (data: Buffer) => { + stderr(data); + } + }, ignoreReturnCode }) - return Promise.resolve(output) + return Promise.resolve(output); } export function stdout(data: Buffer | string): void { @@ -55,4 +63,4 @@ export function stderr(data: Buffer | string): void { ) { output.stderr += dataString } -} +} \ No newline at end of file