From 815b99b98b3e921234d685d4743d0b12d10489fb Mon Sep 17 00:00:00 2001 From: Chrs Borckholder Date: Fri, 14 Jul 2017 11:30:19 +0200 Subject: [PATCH] Avoid clobbering Install-Module If the Install-Module command is available, do not include the bundled module path containing a deprecated version of PSGet. Recent powershell versions include PowerShellGet as standard module installer. Resolve #1318. --- vendor/profile.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vendor/profile.ps1 b/vendor/profile.ps1 index 7878ff2..ccb858e 100644 --- a/vendor/profile.ps1 +++ b/vendor/profile.ps1 @@ -17,10 +17,14 @@ if(!$PSScriptRoot) { $PSScriptRoot = Split-Path $Script:MyInvocation.MyCommand.Path } +# do not load bundled psget if a module installer is already available +# -> recent PowerShell versions include PowerShellGet out of the box +$moduleInstallerAvailable = [bool](Get-Command -Name 'Install-Module' -ErrorAction SilentlyContinue | Out-Null) + # Add Cmder modules directory to the autoload path. $CmderModulePath = Join-path $PSScriptRoot "psmodules/" -if( -not $env:PSModulePath.Contains($CmderModulePath) ){ +if(-not $moduleInstallerAvailable -and -not $env:PSModulePath.Contains($CmderModulePath) ){ $env:PSModulePath = $env:PSModulePath.Insert(0, "$CmderModulePath;") }