From dd658199fc26a4de77514a20f5bc8297d6cae395 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Thu, 8 Jul 2021 15:10:35 +0200 Subject: [PATCH] `Invoke-Git`: Fix new line in returned strings (#94) - `Invoke-Git` - No longer write a new line to the end of string for the returned properties `StandardOutput` and `StandardError`. --- CHANGELOG.md | 4 +++- source/Public/Invoke-Git.ps1 | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f697033..6feb862 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,11 +44,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Enabled the function to extract the comment block if it is not at the top of the script file to support composite resources. - Updated code to pass newly added quality checks. -- `Invoke-Git` +- `Invoke-Git` - Converted to public function. - Updated to use `System.Diagnostics.Process` for improved error handling. - Returns object, allowing caller to process result. - `git` commands no longer use `--quiet` to populate returned object. + - No longer write a new line to the end of string for the returned properties + `StandardOutput` and `StandardError`. ### Fixed diff --git a/source/Public/Invoke-Git.ps1 b/source/Public/Invoke-Git.ps1 index fe52909..758f439 100644 --- a/source/Public/Invoke-Git.ps1 +++ b/source/Public/Invoke-Git.ps1 @@ -79,6 +79,10 @@ function Invoke-Git $returnValue.ExitCode = $process.ExitCode $returnValue.StandardOutput = $process.StandardOutput.ReadToEnd() $returnValue.StandardError = $process.StandardError.ReadToEnd() + + # Remove all new lines at end of string. + $returnValue.StandardOutput = $returnValue.StandardOutput -replace '[\r?\n]+$' + $returnValue.StandardError = $returnValue.StandardError -replace '[\r?\n]+$' } } }