feat(core): Add -Silent switch for Invoke-ExternalCommand (#5346)

This commit is contained in:
L. Yeung
2023-03-11 21:39:45 +08:00
committed by GitHub
parent 559c6f9e64
commit 41620bb169
2 changed files with 29 additions and 21 deletions

View File

@@ -5,6 +5,7 @@
- **scoop-update:** Add support for parallel syncing buckets in PowerShell 7 and improve output ([#5122](https://github.com/ScoopInstaller/Scoop/issues/5122))
- **config:** Support portable config file ([#5369](https://github.com/ScoopInstaller/Scoop/issues/5369))
- **bucket:** Make official buckets higher priority ([#5398](https://github.com/ScoopInstaller/Scoop/issues/5398))
- **core:** Add `-Quiet` switch for `Invoke-ExternalCommand` ([#5346](https://github.com/ScoopInstaller/Scoop/issues/5346))
### Bug Fixes

View File

@@ -568,6 +568,9 @@ function Invoke-ExternalCommand {
[Parameter(ParameterSetName = "UseShellExecute")]
[Switch]
$RunAs,
[Parameter(ParameterSetName = "UseShellExecute")]
[Switch]
$Quiet,
[Alias("Msg")]
[String]
$Activity,
@@ -597,9 +600,12 @@ function Invoke-ExternalCommand {
if ($RunAs) {
$Process.StartInfo.UseShellExecute = $true
$Process.StartInfo.Verb = 'RunAs'
} else {
$Process.StartInfo.CreateNoWindow = $true
}
if ($Quiet) {
$Process.StartInfo.UseShellExecute = $true
$Process.StartInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden
}
if ($ArgumentList.Length -gt 0) {
if ($FilePath -match '^((cmd|cscript|wscript|msiexec)(\.exe)?|.*\.(bat|cmd|js|vbs|wsf))$') {
$Process.StartInfo.Arguments = $ArgumentList -join ' '
} elseif ($Process.StartInfo.ArgumentList.Add) {
@@ -621,6 +627,7 @@ function Invoke-ExternalCommand {
}
$Process.StartInfo.Arguments = $escapedArgs -join ' '
}
}
try {
[void]$Process.Start()
} catch {