fix: powershell exports config files as utf8 without BOM

This commit is contained in:
Michael LoPresti 2021-03-06 05:58:06 +00:00 committed by Jan De Dobbeleer
parent 37e96de87e
commit 90cd37e516

View file

@ -89,10 +89,15 @@ function Export-PoshTheme {
$config = $global:PoshSettings.Theme
$poshCommand = Get-PoshCommand
# Save current encoding and swap for UTF8
# Save current encoding and swap for UTF8 without BOM
$originalOutputEncoding = [Console]::OutputEncoding
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
& $poshCommand -config $config -print-config | Out-File -FilePath $FilePath
[Console]::OutputEncoding = [Text.UTF8Encoding]::new($false)
# Create Config File
$configString = & $poshCommand -config $config -print-config
[IO.File]::WriteAllLines($FilePath, $configString)
# Restore initial encoding
[Console]::OutputEncoding = $originalOutputEncoding
}