From 60555057c25e0f0adf90cf32c3d79f81598a8e78 Mon Sep 17 00:00:00 2001 From: Victor Hallberg Date: Thu, 20 Jul 2023 13:58:12 +0200 Subject: [PATCH] Fixes #2823 - Handles stdout/stderr Buffers in shell run() --- CHANGELOG.md | 1 + src/env/node/git/shell.ts | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef1b656e4b404..7359442b71691 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Changes _Compact Graph Column Layout_ context menu command to _Use Compact Graph Column_ for better clarity - Changes _Default Graph Column Layout_ context menu command to _Use Expanded Graph Column_ for better clarity - Improves remote parsing for better integration support for some edge cases +- Improves error handling of shell commands in certain cases ## [14.1.1] - 2023-07-18 diff --git a/src/env/node/git/shell.ts b/src/env/node/git/shell.ts index 9825fbf9799ad..48ef756748172 100644 --- a/src/env/node/git/shell.ts +++ b/src/env/node/git/shell.ts @@ -245,11 +245,12 @@ export function run( error.message = `Command output exceeded the allocated stdout buffer. Set 'options.maxBuffer' to a larger value than ${opts.maxBuffer} bytes`; } - let stdoutDecoded; - let stderrDecoded; + let stdoutDecoded: string; + let stderrDecoded: string; if (encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer') { - stdoutDecoded = stdout; - stderrDecoded = stderr; + // stdout & stderr can be `Buffer` or `string + stdoutDecoded = stdout.toString(); + stderrDecoded = stderr.toString(); } else { const decode = (await import(/* webpackChunkName: "encoding" */ 'iconv-lite')).decode; stdoutDecoded = decode(Buffer.from(stdout, 'binary'), encoding);