Skip to content

Commit

Permalink
Remove unnecessary variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbergstrom committed Nov 17, 2019
1 parent b87c185 commit 9de3d7c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 25 deletions.
25 changes: 13 additions & 12 deletions ChocolateyGet.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}
}
4 changes: 2 additions & 2 deletions src/private/Install-ChocoBinaries.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions src/private/MiscHelpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
6 changes: 2 additions & 4 deletions src/private/PackageNameHelpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
}
3 changes: 1 addition & 2 deletions src/private/PackageVersionHelpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 1 addition & 3 deletions src/public/Install-Package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 9de3d7c

Please sign in to comment.