Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Commit c708c79

Browse files
ThomasNietoalerickson
authored andcommitted
Add PSPath alias to LiteralPath parameter (#489)
1 parent 0f667f2 commit c708c79

File tree

5 files changed

+296
-380
lines changed

5 files changed

+296
-380
lines changed

src/PowerShellGet/public/psgetfunctions/Publish-Script.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function Publish-Script {
1818
[Parameter(Mandatory = $true,
1919
ValueFromPipelineByPropertyName = $true,
2020
ParameterSetName = 'LiteralPathParameterSet')]
21+
[Alias('PSPath')]
2122
[ValidateNotNullOrEmpty()]
2223
[string]
2324
$LiteralPath,
@@ -49,7 +50,7 @@ function Publish-Script {
4950
$scriptFilePath = $null
5051
if ($Path) {
5152
$scriptFilePath = Resolve-PathHelper -Path $Path -CallerPSCmdlet $PSCmdlet |
52-
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
53+
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
5354

5455
if (-not $scriptFilePath -or
5556
-not (Microsoft.PowerShell.Management\Test-Path -Path $scriptFilePath -PathType Leaf)) {
@@ -64,7 +65,7 @@ function Publish-Script {
6465
}
6566
else {
6667
$scriptFilePath = Resolve-PathHelper -Path $LiteralPath -IsLiteralPath -CallerPSCmdlet $PSCmdlet |
67-
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
68+
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
6869

6970
if (-not $scriptFilePath -or
7071
-not (Microsoft.PowerShell.Management\Test-Path -LiteralPath $scriptFilePath -PathType Leaf)) {
@@ -117,8 +118,7 @@ function Publish-Script {
117118

118119
if (-not $DestinationLocation -or
119120
(-not (Microsoft.PowerShell.Management\Test-Path -Path $DestinationLocation) -and
120-
-not (Test-WebUri -uri $DestinationLocation)))
121-
{
121+
-not (Test-WebUri -uri $DestinationLocation))) {
122122
$message = $LocalizedData.PSRepositoryScriptPublishLocationIsMissing -f ($Repository, $Repository)
123123
ThrowError -ExceptionName "System.ArgumentException" `
124124
-ExceptionMessage $message `
@@ -182,7 +182,7 @@ function Publish-Script {
182182

183183
# Copy the source script file to temp location to publish
184184
$tempScriptPath = Microsoft.PowerShell.Management\Join-Path -Path $script:TempPath -ChildPath "$(Get-Random)" |
185-
Microsoft.PowerShell.Management\Join-Path -ChildPath $scriptName
185+
Microsoft.PowerShell.Management\Join-Path -ChildPath $scriptName
186186

187187
$null = Microsoft.PowerShell.Management\New-Item -Path $tempScriptPath -ItemType Directory -Force -ErrorAction SilentlyContinue -WarningAction SilentlyContinue -Confirm:$false -WhatIf:$false
188188
if ($Path) {
@@ -211,8 +211,8 @@ function Publish-Script {
211211
# Check if the specified script name is already used for a module on the specified repository
212212
# Use Find-Module to check if that name is already used as module name
213213
$modulePSGetItemInfo = Find-Module @FindParameters |
214-
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $scriptName} |
215-
Microsoft.PowerShell.Utility\Select-Object -Last 1 -ErrorAction Ignore
214+
Microsoft.PowerShell.Core\Where-Object { $_.Name -eq $scriptName } |
215+
Microsoft.PowerShell.Utility\Select-Object -Last 1 -ErrorAction Ignore
216216
if ($modulePSGetItemInfo) {
217217
$message = $LocalizedData.SpecifiedNameIsAlearyUsed -f ($scriptName, $Repository, 'Find-Module')
218218
ThrowError -ExceptionName "System.InvalidOperationException" `
@@ -227,8 +227,8 @@ function Publish-Script {
227227

228228
$currentPSGetItemInfo = $null
229229
$currentPSGetItemInfo = Find-Script @FindParameters |
230-
Microsoft.PowerShell.Core\Where-Object {$_.Name -eq $scriptName} |
231-
Microsoft.PowerShell.Utility\Select-Object -Last 1 -ErrorAction Ignore
230+
Microsoft.PowerShell.Core\Where-Object { $_.Name -eq $scriptName } |
231+
Microsoft.PowerShell.Utility\Select-Object -Last 1 -ErrorAction Ignore
232232

233233
if ($currentPSGetItemInfo) {
234234
$result = ValidateAndGet-VersionPrereleaseStrings -Version $currentPSGetItemInfo.Version -CallerPSCmdlet $PSCmdlet

src/PowerShellGet/public/psgetfunctions/Save-Module.ps1

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,24 @@ function Save-Module {
6565
[string[]]
6666
$Repository,
6767

68-
[Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'NameAndPathParameterSet')]
69-
[Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'InputObjectAndPathParameterSet')]
68+
[Parameter(Mandatory = $true,
69+
Position = 1,
70+
ValueFromPipelineByPropertyName = $true,
71+
ParameterSetName = 'NameAndPathParameterSet')]
72+
[Parameter(Mandatory = $true,
73+
Position = 1,
74+
ValueFromPipelineByPropertyName = $true,
75+
ParameterSetName = 'InputObjectAndPathParameterSet')]
7076
[string]
7177
$Path,
7278

73-
[Parameter(Mandatory = $true, ParameterSetName = 'NameAndLiteralPathParameterSet')]
74-
[Parameter(Mandatory = $true, ParameterSetName = 'InputObjectAndLiteralPathParameterSet')]
79+
[Parameter(Mandatory = $true,
80+
ValueFromPipelineByPropertyName = $true,
81+
ParameterSetName = 'NameAndLiteralPathParameterSet')]
82+
[Parameter(Mandatory = $true,
83+
ValueFromPipelineByPropertyName = $true,
84+
ParameterSetName = 'InputObjectAndLiteralPathParameterSet')]
85+
[Alias('PSPath')]
7586
[string]
7687
$LiteralPath,
7788

@@ -189,8 +200,7 @@ function Save-Module {
189200
($inputValue.PSTypeNames -notcontains "Microsoft.PowerShell.Commands.PSGetDscResourceInfo") -and
190201
($inputValue.PSTypeNames -notcontains "Deserialized.Microsoft.PowerShell.Commands.PSGetDscResourceInfo") -and
191202
($inputValue.PSTypeNames -notcontains "Microsoft.PowerShell.Commands.PSGetRoleCapabilityInfo") -and
192-
($inputValue.PSTypeNames -notcontains "Deserialized.Microsoft.PowerShell.Commands.PSGetRoleCapabilityInfo"))
193-
{
203+
($inputValue.PSTypeNames -notcontains "Deserialized.Microsoft.PowerShell.Commands.PSGetRoleCapabilityInfo")) {
194204
ThrowError -ExceptionName "System.ArgumentException" `
195205
-ExceptionMessage $LocalizedData.InvalidInputObjectValue `
196206
-ErrorId "InvalidInputObjectValue" `

src/PowerShellGet/public/psgetfunctions/Save-Script.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ function Save-Script {
8484
[Parameter(Mandatory = $true,
8585
ValueFromPipelineByPropertyName = $true,
8686
ParameterSetName = 'InputObjectAndLiteralPathParameterSet')]
87+
[Alias('PSPath')]
8788
[string]
8889
$LiteralPath,
8990

@@ -134,7 +135,7 @@ function Save-Script {
134135
if (-not $Force) {
135136
if ($Path) {
136137
$destinationPath = Resolve-PathHelper -Path $Path -CallerPSCmdlet $PSCmdlet |
137-
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
138+
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
138139

139140
if (-not $destinationPath -or -not (Microsoft.PowerShell.Management\Test-path $destinationPath)) {
140141
$errorMessage = ($LocalizedData.PathNotFound -f $Path)
@@ -150,7 +151,7 @@ function Save-Script {
150151
}
151152
else {
152153
$destinationPath = Resolve-PathHelper -Path $LiteralPath -IsLiteralPath -CallerPSCmdlet $PSCmdlet |
153-
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
154+
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
154155

155156
if (-not $destinationPath -or -not (Microsoft.PowerShell.Management\Test-Path -LiteralPath $destinationPath)) {
156157
$errorMessage = ($LocalizedData.PathNotFound -f $LiteralPath)

0 commit comments

Comments
 (0)