From 9f99c1c056a1697ad4a3695602b59a05bda95d19 Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Sun, 8 Dec 2024 20:37:24 -0500 Subject: [PATCH] fix: trim output lines before splitting --- lib/Git.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Git.js b/lib/Git.js index 478a789..a4346bd 100644 --- a/lib/Git.js +++ b/lib/Git.js @@ -452,14 +452,14 @@ class Git { const process = child_process.spawn(this.command, commandArgs, execOptions); if (execOptions.passthrough) { - process.stdout.on('data', data => data.toString().split(/\n/).forEach(line => logger.info(line.trimEnd()))); - process.stderr.on('data', data => data.toString().split(/\n/).forEach(line => logger.error(line.trimEnd()))); + process.stdout.on('data', data => data.toString().trimEnd().split(/\n/).forEach(line => logger.info(line.trimEnd()))); + process.stderr.on('data', data => data.toString().trimEnd().split(/\n/).forEach(line => logger.error(line.trimEnd()))); } else { if (execOptions.onStdout) { - process.stdout.on('data', data => data.toString().split(/\n/).forEach(line => execOptions.onStdout(line.trimEnd()))); + process.stdout.on('data', data => data.toString().trimEnd().split(/\n/).forEach(line => execOptions.onStdout(line.trimEnd()))); } if (execOptions.onStderr) { - process.stderr.on('data', data => data.toString().split(/\n/).forEach(line => execOptions.onStderr(line.trimEnd()))); + process.stderr.on('data', data => data.toString().trimEnd().split(/\n/).forEach(line => execOptions.onStderr(line.trimEnd()))); } }