diff --git a/ChocolateyGet.psd1 b/ChocolateyGet.psd1 index 24f5f7f..aa533c9 100644 --- a/ChocolateyGet.psd1 +++ b/ChocolateyGet.psd1 @@ -7,22 +7,23 @@ Description = 'A PowerShell OneGet provider that discovers Chocolatey packages from NuGet repositories' PowerShellVersion = '3.0' RequiredModules = @('PackageManagement') - PrivateData = @{"PackageManagementProviders" = 'ChocolateyGet.psm1' - PSData = @{ - # Tags applied to this module to indicate this is a PackageManagement Provider. - Tags = @("PackageManagement","Provider") + PrivateData = @{ + PackageManagementProviders = 'ChocolateyGet.psm1' + PSData = @{ + # Tags applied to this module to indicate this is a PackageManagement Provider. + Tags = @("PackageManagement","Provider") - # A URL to the license for this module. - LicenseUri = 'https://github.com/PowerShell/PowerShell/blob/master/LICENSE.txt' + # A URL to the license for this module. + LicenseUri = 'https://github.com/PowerShell/PowerShell/blob/master/LICENSE.txt' - # A URL to the main website for this project. - ProjectUri = 'https://github.com/Jianyunt/ChocolateyGet' + # A URL to the main website for this project. + ProjectUri = 'https://github.com/Jianyunt/ChocolateyGet' - # ReleaseNotes of this module - ReleaseNotes = 'This is a PowerShell OneGet provider. It is a wrapper on top of Choco. - It discovers Chocolatey packages from https://www.chocolatey.org and other NuGet repos.' + # ReleaseNotes of this module + ReleaseNotes = 'This is a PowerShell OneGet provider. It is a wrapper on top of Choco. + It discovers Chocolatey packages from https://www.chocolatey.org and other NuGet repos.' - ExternalModuleDependencies = @('PackageManagement') + ExternalModuleDependencies = @('PackageManagement') } } } diff --git a/src/private/Install-ChocoBinaries.ps1 b/src/private/Install-ChocoBinaries.ps1 index ec53655..9d15580 100644 --- a/src/private/Install-ChocoBinaries.ps1 +++ b/src/private/Install-ChocoBinaries.ps1 @@ -27,8 +27,8 @@ function Install-ChocoBinaries { Invoke-WebRequest 'https://chocolatey.org/install.ps1' -UseBasicParsing | Invoke-Expression > $null } catch { ThrowError -ExceptionName 'System.OperationCanceledException' ` - -ExceptionMessage $LocalizedData.SearchingEntireRepo ` - -ErrorID 'JobFailure' ` + -ExceptionMessage $LocalizedData.FailToInstallChoco ` + -ErrorID 'FailToInstallChoco' ` -ErrorCategory InvalidOperation ` -ExceptionObject $job } diff --git a/src/private/MiscHelpers.ps1 b/src/private/MiscHelpers.ps1 index 4653bc7..731619c 100644 --- a/src/private/MiscHelpers.ps1 +++ b/src/private/MiscHelpers.ps1 @@ -64,7 +64,6 @@ function ThrowError { $ErrorCategory ) - $exception = New-Object $ExceptionName $ExceptionMessage - $errorRecord = New-Object System.Management.Automation.ErrorRecord $exception, $ErrorId, $ErrorCategory, $ExceptionObject + $errorRecord = New-Object System.Management.Automation.ErrorRecord (New-Object $ExceptionName $ExceptionMessage), $ErrorId, $ErrorCategory, $ExceptionObject $CallerPSCmdlet.ThrowTerminatingError($errorRecord) } diff --git a/src/private/PackageNameHelpers.ps1 b/src/private/PackageNameHelpers.ps1 index bc9cfef..50902fe 100644 --- a/src/private/PackageNameHelpers.ps1 +++ b/src/private/PackageNameHelpers.ps1 @@ -24,12 +24,10 @@ function Test-PackageName { $RequestedName ) - $nameRegex=$RequestedName.TrimStart('*') - $nameRegex=$nameRegex.TrimEnd('.') - $nameRegex="^.*$nameRegex.*$" + $nameRegex='^.*'+($RequestedName.TrimStart('*')).TrimEnd('.')+'.*$' # Return true if the package name returned from choco matched what we were expecting - ($PackageName -match "$nameRegex") -and ( + ($PackageName -match $nameRegex) -and ( ($RequestedName -eq $PackageName) -or (Test-WildcardPattern -name $RequestedName) ) } diff --git a/src/private/PackageVersionHelpers.ps1 b/src/private/PackageVersionHelpers.ps1 index c73933d..9971549 100644 --- a/src/private/PackageVersionHelpers.ps1 +++ b/src/private/PackageVersionHelpers.ps1 @@ -89,9 +89,8 @@ function Confirm-VersionParameters -ErrorId "VersionRangeAndRequiredVersionCannotBeSpecifiedTogether" ` -ErrorCategory InvalidArgument } elseif ($MinimumVersion -and $MaximumVersion -and ($MinimumVersion -gt $MaximumVersion)) { - $Message = $LocalizedData.MinimumVersionIsGreaterThanMaximumVersion -f ($MinimumVersion, $MaximumVersion) ThrowError -ExceptionName "System.ArgumentException" ` - -ExceptionMessage $Message ` + -ExceptionMessage ($LocalizedData.MinimumVersionIsGreaterThanMaximumVersion -f ($MinimumVersion, $MaximumVersion)) ` -ErrorId "MinimumVersionIsGreaterThanMaximumVersion" ` -ErrorCategory InvalidArgument } elseif ($AllVersions -or $RequiredVersion -or $MinimumVersion -or $MaximumVersion) { diff --git a/src/public/Install-Package.ps1 b/src/public/Install-Package.ps1 index 6254384..dfd8e4e 100644 --- a/src/public/Install-Package.ps1 +++ b/src/public/Install-Package.ps1 @@ -19,13 +19,11 @@ function Install-Package { -ErrorCategory InvalidArgument } - $force = Get-ForceProperty - $shouldContinueQueryMessage = ($LocalizedData.InstallPackageQuery -f "Installing", $Matches.name) $shouldContinueCaption = $LocalizedData.InstallPackageCaption # If the user opts not to install the package, exit from the script - if (-not ($Force -or $request.ShouldContinue($shouldContinueQueryMessage, $shouldContinueCaption))) { + if (-not ((Get-ForceProperty) -or $request.ShouldContinue($shouldContinueQueryMessage, $shouldContinueCaption))) { Write-Warning ($LocalizedData.NotInstalled -f $FastPackageReference) return }