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

Add PassThru parameter to Install/Update functions #487

Merged
merged 14 commits into from
May 31, 2019
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add Update-Script PassThru parameter
  • Loading branch information
ThomasNieto committed May 30, 2019
commit 9cae2690253d831ed4de3a3f81e7b4e8b83ea963
15 changes: 12 additions & 3 deletions src/PowerShellGet/public/psgetfunctions/Update-Script.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ function Update-Script {

[Parameter()]
[switch]
$AcceptLicense
$AcceptLicense,

[Parameter()]
[switch]
$PassThru
)

Begin {
Expand All @@ -70,7 +74,7 @@ function Update-Script {
return
}

if(-not $Name) {
if (-not $Name) {
$Name = @('*')
}

Expand All @@ -87,7 +91,7 @@ function Update-Script {
foreach ($scriptFilePath in $availableScriptPaths) {
# Check if this script got installed with PowerShellGet
$installedScriptFilePath = Get-InstalledScriptFilePath -Name ([System.IO.Path]::GetFileNameWithoutExtension($scriptFilePath)) |
Microsoft.PowerShell.Core\Where-Object {$_ -eq $scriptFilePath }
Microsoft.PowerShell.Core\Where-Object { $_ -eq $scriptFilePath }

if ($installedScriptFilePath) {
$scriptFilePathsToUpdate += $installedScriptFilePath
Expand Down Expand Up @@ -162,9 +166,14 @@ function Update-Script {
$PSBoundParameters[$script:AllowPrereleaseVersions] = $true
}
$null = $PSBoundParameters.Remove("AllowPrerelease")
$null = $PSBoundParameters.Remove("PassThru")

$PSBoundParameters["Scope"] = Get-InstallationScope -PreviousInstallLocation $scriptFilePath -CurrentUserPath $script:MyDocumentsScriptsPath
$sid = PackageManagement\Install-Package @PSBoundParameters

if ($PassThru) {
$sid | Microsoft.PowerShell.Core\ForEach-Object { New-PSGetItemInfo -SoftwareIdentity $_ -Type $script:PSArtifactTypeScript }
}
}
}
}