Skip to content

Commit

Permalink
Add a flag to suppress deprecation warning
Browse files Browse the repository at this point in the history
Allow Powershell 2 support deprecation warning to be suppressed by
importing the module with a true value as an argument.

The ability to pass arguments through Import-Module is pretty limited,
accepting only positional arguments, but it still seems a preferable
option to environment variables or asking users to modify posh-git
directly.

Closes dahlbyk#163
  • Loading branch information
theaquamarine committed Apr 14, 2015
1 parent 6345d25 commit 0325a0e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions posh-git.psm1
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
param([switch]$NoVersionWarn = $false)

if (Get-Module posh-git) { return }

if ($PSVersionTable.PSVersion.Major -lt 3) {
if ($PSVersionTable.PSVersion.Major -lt 3 -and !$NoVersionWarn) {
Write-Warning ("posh-git support for PowerShell 2.0 is deprecated; you have version $($Host.Version).`n" +
"To download version 3.0, please visit https://www.microsoft.com/en-us/download/details.aspx?id=34595`n" +
"For more information and to discuss this, please visit https://github.com/dahlbyk/posh-git/issues/163`n")
"For more information and to discuss this, please visit https://github.com/dahlbyk/posh-git/issues/163`n" +
"To suppress this warning, change your profile to include 'Import-Module posh-git -Args `$true'.")
}

Push-Location $psScriptRoot
Expand Down

0 comments on commit 0325a0e

Please sign in to comment.