Fix adding Import-Module command to the profile in Install-PSPackage

This commit is contained in:
Shivam Mathur 2022-02-08 01:02:16 +05:30
parent ce2a129c36
commit 0cfde7beae
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A

View File

@ -166,10 +166,10 @@ Function Install-PSPackage() {
Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force
}
Import-Module $module_path
Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
if($null -eq (Get-Command $cmdlet -ErrorAction SilentlyContinue)) {
Install-Module -Name $package -Force
} else {
Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
}
}