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);