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

Add PSPath alias to LiteralPath parameter #489

Merged
merged 1 commit into from
May 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/PowerShellGet/public/psgetfunctions/Publish-Script.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function Publish-Script {
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
ParameterSetName = 'LiteralPathParameterSet')]
[Alias('PSPath')]
[ValidateNotNullOrEmpty()]
[string]
$LiteralPath,
Expand Down Expand Up @@ -49,7 +50,7 @@ function Publish-Script {
$scriptFilePath = $null
if ($Path) {
$scriptFilePath = Resolve-PathHelper -Path $Path -CallerPSCmdlet $PSCmdlet |
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore
Microsoft.PowerShell.Utility\Select-Object -First 1 -ErrorAction Ignore

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

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

if (-not $DestinationLocation -or
(-not (Microsoft.PowerShell.Management\Test-Path -Path $DestinationLocation) -and
-not (Test-WebUri -uri $DestinationLocation)))
{
-not (Test-WebUri -uri $DestinationLocation))) {
$message = $LocalizedData.PSRepositoryScriptPublishLocationIsMissing -f ($Repository, $Repository)
ThrowError -ExceptionName "System.ArgumentException" `
-ExceptionMessage $message `
Expand Down Expand Up @@ -182,7 +182,7 @@ function Publish-Script {

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

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

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

if ($currentPSGetItemInfo) {
$result = ValidateAndGet-VersionPrereleaseStrings -Version $currentPSGetItemInfo.Version -CallerPSCmdlet $PSCmdlet
Expand Down
22 changes: 16 additions & 6 deletions src/PowerShellGet/public/psgetfunctions/Save-Module.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,24 @@ function Save-Module {
[string[]]
$Repository,

[Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'NameAndPathParameterSet')]
[Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'InputObjectAndPathParameterSet')]
[Parameter(Mandatory = $true,
Position = 1,
ValueFromPipelineByPropertyName = $true,
ParameterSetName = 'NameAndPathParameterSet')]
[Parameter(Mandatory = $true,
Position = 1,
ValueFromPipelineByPropertyName = $true,
ParameterSetName = 'InputObjectAndPathParameterSet')]
[string]
$Path,

[Parameter(Mandatory = $true, ParameterSetName = 'NameAndLiteralPathParameterSet')]
[Parameter(Mandatory = $true, ParameterSetName = 'InputObjectAndLiteralPathParameterSet')]
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
ParameterSetName = 'NameAndLiteralPathParameterSet')]
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
ParameterSetName = 'InputObjectAndLiteralPathParameterSet')]
[Alias('PSPath')]
[string]
$LiteralPath,

Expand Down Expand Up @@ -189,8 +200,7 @@ function Save-Module {
($inputValue.PSTypeNames -notcontains "Microsoft.PowerShell.Commands.PSGetDscResourceInfo") -and
($inputValue.PSTypeNames -notcontains "Deserialized.Microsoft.PowerShell.Commands.PSGetDscResourceInfo") -and
($inputValue.PSTypeNames -notcontains "Microsoft.PowerShell.Commands.PSGetRoleCapabilityInfo") -and
($inputValue.PSTypeNames -notcontains "Deserialized.Microsoft.PowerShell.Commands.PSGetRoleCapabilityInfo"))
{
($inputValue.PSTypeNames -notcontains "Deserialized.Microsoft.PowerShell.Commands.PSGetRoleCapabilityInfo")) {
ThrowError -ExceptionName "System.ArgumentException" `
-ExceptionMessage $LocalizedData.InvalidInputObjectValue `
-ErrorId "InvalidInputObjectValue" `
Expand Down
5 changes: 3 additions & 2 deletions src/PowerShellGet/public/psgetfunctions/Save-Script.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function Save-Script {
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
ParameterSetName = 'InputObjectAndLiteralPathParameterSet')]
[Alias('PSPath')]
[string]
$LiteralPath,

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

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

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