Skip to content

Commit

Permalink
Fixes gitkraken#2823 - Handles stdout/stderr Buffers in shell run()
Browse files Browse the repository at this point in the history
  • Loading branch information
mogelbrod committed Jul 20, 2023
1 parent 2ddb8f0 commit 6055505
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 5 additions & 4 deletions src/env/node/git/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,12 @@ export function run<T extends number | string | Buffer>(
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);
Expand Down

0 comments on commit 6055505

Please sign in to comment.