-
-
Notifications
You must be signed in to change notification settings - Fork 811
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update install to use Add-PoshGitToProfile
- Loading branch information
Showing
1 changed file
with
2 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,6 @@ | ||
param([switch]$WhatIf = $false) | ||
|
||
# Dot source for Get-FileEncoding | ||
$installDir = Split-Path $MyInvocation.MyCommand.Path -Parent | ||
. $installDir\Utils.ps1 | ||
|
||
if($PSVersionTable.PSVersion.Major -lt 2) { | ||
Write-Warning "posh-git requires PowerShell 2.0 or better; you have version $($Host.Version)." | ||
return | ||
} | ||
|
||
if(!(Test-Path $PROFILE)) { | ||
Write-Host "Creating PowerShell profile...`n$PROFILE" | ||
New-Item $PROFILE -Force -Type File -ErrorAction Stop -WhatIf:$WhatIf > $null | ||
} | ||
|
||
if(!(Get-Command git -ErrorAction SilentlyContinue)) { | ||
Write-Warning 'Could not find git command. Please create a git alias or add %ProgramFiles%\Git\cmd to PATH.' | ||
return | ||
} | ||
|
||
if(!(. (Join-Path $installDir "CheckVersion.ps1"))) { | ||
return | ||
} | ||
|
||
$profileLine = ". '$installDir\profile.example.ps1'" | ||
if(Select-String -Path $PROFILE -Pattern $profileLine -Quiet -SimpleMatch) { | ||
Write-Host "It seems posh-git is already installed..." | ||
return | ||
} | ||
|
||
Write-Host "Adding posh-git to profile..." | ||
@" | ||
# Load posh-git example profile | ||
$profileLine | ||
"@ | Out-File $PROFILE -Append -WhatIf:$WhatIf -Encoding (Get-FileEncoding $PROFILE) | ||
|
||
Write-Host 'posh-git sucessfully installed!' | ||
Write-Host 'Please reload your profile for the changes to take effect:' | ||
Write-Host ' . $PROFILE' | ||
Import-Module $installDir\posh-git.psd1 | ||
Add-PoshGitToProfile -WhatIf:$WhatIf |