Skip to content

Commit

Permalink
Update install to use Add-PoshGitToProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlbyk committed Jan 16, 2017
1 parent a1febc2 commit 99edc92
Showing 1 changed file with 2 additions and 38 deletions.
40 changes: 2 additions & 38 deletions install.ps1
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

0 comments on commit 99edc92

Please sign in to comment.