1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-11-04 20:37:56 +00:00

fix(init): make log messages on pwsh visible again (#2295)

This commit is contained in:
David Knaack 2021-02-13 19:31:54 +01:00 committed by GitHub
parent cf9c89ef6b
commit a24e843ee0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,6 +27,7 @@ function global:prompt {
$startInfo = [System.Diagnostics.ProcessStartInfo]::new($Executable);
$startInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8;
$startInfo.RedirectStandardOutput = $true;
$startInfo.RedirectStandardError = $true;
$startInfo.CreateNoWindow = $true;
$startInfo.UseShellExecute = $false;
if ($startInfo.ArgumentList.Add) {
@ -48,7 +49,17 @@ function global:prompt {
}
$startInfo.Arguments = $escaped -Join ' ';
}
[System.Diagnostics.Process]::Start($startInfo).StandardOutput.ReadToEnd();
$process = [System.Diagnostics.Process]::Start($startInfo)
# stderr isn't displayed with this style of invocation
# Manually write it to console
$stderr = $process.StandardError.ReadToEnd().Trim()
if ($stderr -ne '') {
# Write-Error doesn't work here
$host.ui.WriteErrorLine($stderr)
}
$process.StandardOutput.ReadToEnd();
}
$origDollarQuestion = $global:?