Skip to content

Commit

Permalink
fix: Function placement
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash258 committed Oct 17, 2021
1 parent 7255a0c commit 6d65a20
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 48 deletions.
48 changes: 48 additions & 0 deletions lib/Applications.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,51 @@ function app_status($app, $global) {

return $status
}

function Confirm-InstallationStatus {
<#
.SYNOPSIS
Get status of specific applications.
Returns array of 3 item arrays (appliation name, globally installed, bucket name)
.PARAMETER Apps
Specifies the array of applications to be evalueated.
.PARAMETER Global
Specifies to check globally installed applications.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[String[]] $Apps,
[Switch] $Global
)
$Global | Out-Null # PowerShell/PSScriptAnalyzer#1472
$installed = @()

$Apps | Select-Object -Unique | Where-Object -Property 'Name' -NE -Value 'scoop' | ForEach-Object {
# TODO: Adopt Resolve-ManifestInformation
# Should not be needed to resolve, as it will contain only valid installed applications
$app, $null, $null = parse_app $_
$buc = (app_status $app $Global).bucket
if ($Global) {
if (installed $app $true) {
$installed += , @($app, $true, $buc)
} elseif (installed $app $false) {
Write-UserMessage -Message "'$app' isn't installed globally, but it is installed for your account." -Err
Write-UserMessage -Message 'Try again without the --global (or -g) flag instead.' -Warning
} else {
Write-UserMessage -Message "'$app' isn't installed." -Err
}
} else {
if (installed $app $false) {
$installed += , @($app, $false, $buc)
} elseif (installed $app $true) {
Write-UserMessage -Message "'$app' isn't installed for your account, but it is installed globally." -Err
Write-UserMessage -Message 'Try again with the --global (or -g) flag instead.' -Warning
} else {
Write-UserMessage -Message "'$app' isn't installed." -Err
}
}
}

return , $installed
}
48 changes: 0 additions & 48 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -812,54 +812,6 @@ function ensure_architecture($architecture_opt) {
}
}

function Confirm-InstallationStatus {
<#
.SYNOPSIS
Get status of specific applications.
Returns array of 3 item arrays (appliation name, globally installed, bucket name)
.PARAMETER Apps
Specifies the array of applications to be evalueated.
.PARAMETER Global
Specifies to check globally installed applications.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[String[]] $Apps,
[Switch] $Global
)
$Global | Out-Null # PowerShell/PSScriptAnalyzer#1472
$installed = @()

$Apps | Select-Object -Unique | Where-Object -Property 'Name' -NE -Value 'scoop' | ForEach-Object {
# TODO: Adopt Resolve-ManifestInformation
# Should not be needed to resolve, as it will contain only valid installed applications
$app, $null, $null = parse_app $_
$buc = (app_status $app $Global).bucket
if ($Global) {
if (installed $app $true) {
$installed += , @($app, $true, $buc)
} elseif (installed $app $false) {
Write-UserMessage -Message "'$app' isn't installed globally, but it is installed for your account." -Err
Write-UserMessage -Message 'Try again without the --global (or -g) flag instead.' -Warning
} else {
Write-UserMessage -Message "'$app' isn't installed." -Err
}
} else {
if (installed $app $false) {
$installed += , @($app, $false, $buc)
} elseif (installed $app $true) {
Write-UserMessage -Message "'$app' isn't installed for your account, but it is installed globally." -Err
Write-UserMessage -Message 'Try again with the --global (or -g) flag instead.' -Warning
} else {
Write-UserMessage -Message "'$app' isn't installed." -Err
}
}
}

return , $installed
}

function strip_path($orig_path, $dir) {
if ($null -eq $orig_path) { $orig_path = '' }
$stripped = [string]::join(';', @( $orig_path.split(';') | Where-Object { $_ -and $_ -ne $dir } ))
Expand Down
1 change: 1 addition & 0 deletions libexec/scoop-cleanup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@('getopt', 'Resolve-GetOpt'),
@('help', 'scoop_help'),
@('Helpers', 'New-IssuePrompt'),
@('Applications', 'Get-InstalledApplicationInformation'),
@('buckets', 'Get-KnownBucket'),
@('install', 'install_app'),
@('manifest', 'Resolve-ManifestInformation'),
Expand Down
1 change: 1 addition & 0 deletions libexec/scoop-info.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@('getopt', 'Resolve-GetOpt'),
@('help', 'scoop_help'),
@('Helpers', 'New-IssuePrompt'),
@('Applications', 'Get-InstalledApplicationInformation'),
@('buckets', 'Get-KnownBucket'),
@('depends', 'script_deps'),
@('install', 'install_app'),
Expand Down
1 change: 1 addition & 0 deletions libexec/scoop-uninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@('help', 'scoop_help'),
@('Helpers', 'New-IssuePrompt'),
@('install', 'install_app'),
@('Applications', 'Get-InstalledApplicationInformation'),
@('manifest', 'Resolve-ManifestInformation'),
@('psmodules', 'install_psmodule'),
@('shortcuts', 'rm_startmenu_shortcuts'),
Expand Down
1 change: 1 addition & 0 deletions libexec/scoop-update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@('getopt', 'Resolve-GetOpt'),
@('help', 'scoop_help'),
@('Helpers', 'New-IssuePrompt'),
@('Applications', 'Get-InstalledApplicationInformation'),
@('depends', 'script_deps'),
@('install', 'install_app'),
@('manifest', 'Resolve-ManifestInformation'),
Expand Down

0 comments on commit 6d65a20

Please sign in to comment.