feat: Posh-GitHub / VsVars $PROFILE encoding

- function taken from posh-github, allow us to reliably
   select the appropriate encoding for writing to $PROFILE
This commit is contained in:
Iristyle
2013-05-09 14:07:53 -04:00
parent 2cc8fe18a0
commit 860a6462e5
4 changed files with 6 additions and 2 deletions

View File

@@ -48,5 +48,6 @@ that have been merged into the master branch.
<files> <files>
<file src="tools\**" target="tools" /> <file src="tools\**" target="tools" />
<file src="..\core\PowerShellHelpers.ps1" target="tools" /> <file src="..\core\PowerShellHelpers.ps1" target="tools" />
<file src="..\core\EncodingHelpers.ps1" target="tools" />
</files> </files>
</package> </package>

View File

@@ -10,6 +10,7 @@ function Get-CurrentDirectory
try { try {
$current = Get-CurrentDirectory $current = Get-CurrentDirectory
. (Join-Path $current 'PowerShellHelpers.ps1') . (Join-Path $current 'PowerShellHelpers.ps1')
. (Join-Path $current 'EncodingHelpers.ps1')
# find user specific module directory # find user specific module directory
$moduleDirectory = Get-ModuleDirectory $moduleDirectory = Get-ModuleDirectory
@@ -57,7 +58,7 @@ try {
{ {
$loaderFile = 'Posh-GitHub-Profile.ps1' $loaderFile = 'Posh-GitHub-Profile.ps1'
"`n`n# Load Posh-GitHub`n. '$installDirectory\$loaderFile'" | "`n`n# Load Posh-GitHub`n. '$installDirectory\$loaderFile'" |
Out-File -FilePath $PROFILE -Append -Encoding UTF8 Out-File -FilePath $PROFILE -Append -Encoding (Get-FileEncoding $PROFILE)
. $PROFILE . $PROFILE
} }

View File

@@ -39,5 +39,6 @@ http://www.hanselman.com/blog/AwesomeVisualStudioCommandPromptAndPowerShellIcons
<files> <files>
<file src="tools\**" target="tools" /> <file src="tools\**" target="tools" />
<file src="..\core\PowerShellHelpers.ps1" target="tools" /> <file src="..\core\PowerShellHelpers.ps1" target="tools" />
<file src="..\core\EncodingHelpers.ps1" target="tools" />
</files> </files>
</package> </package>

View File

@@ -9,6 +9,7 @@ function Get-CurrentDirectory
try { try {
$current = Get-CurrentDirectory $current = Get-CurrentDirectory
. (Join-Path $current 'PowerShellHelpers.ps1') . (Join-Path $current 'PowerShellHelpers.ps1')
. (Join-Path $current 'EncodingHelpers.ps1')
$moduleDirectory = Get-ModuleDirectory $moduleDirectory = Get-ModuleDirectory
$installDirectory = Join-Path $moduleDirectory $package $installDirectory = Join-Path $moduleDirectory $package
@@ -56,7 +57,7 @@ try {
{ {
$loaderFile = 'Posh-VsVars-Profile.ps1' $loaderFile = 'Posh-VsVars-Profile.ps1'
"`n`n# Load Posh-VsVars`n. '$installDirectory\$loaderFile'" | "`n`n# Load Posh-VsVars`n. '$installDirectory\$loaderFile'" |
Out-File -FilePath $PROFILE -Append -Encoding UTF8 Out-File -FilePath $PROFILE -Append -Encoding (Get-FileEncoding $PROFILE)
Write-Host 'Reloading PowerShell Profile...' Write-Host 'Reloading PowerShell Profile...'
. $PROFILE . $PROFILE
} }