Files
Scoop/lib/buckets.ps1
T

45 lines
1.1 KiB
PowerShell

$bucketsdir = "$scoopdir\buckets"
function bucketdir($name) {
if(!$name) { return relpath "..\bucket" } # main bucket
"$bucketsdir\$name"
}
function known_bucket_repos {
$dir = versiondir 'scoop' 'current'
$json = "$dir\buckets.json"
Get-Content $json -raw | convertfrom-json -ea stop
}
function known_bucket_repo($name) {
$buckets = known_bucket_repos
$buckets.$name
}
function apps_in_bucket($dir) {
Get-ChildItem $dir | Where-Object { $_.name.endswith('.json') } | ForEach-Object { $_ -replace '.json$', '' }
}
function buckets {
$buckets = @()
if(test-path $bucketsdir) {
Get-ChildItem $bucketsdir | ForEach-Object { $buckets += $_.name }
}
$buckets
}
function find_manifest($app, $bucket) {
if ($bucket) {
$manifest = manifest $app $bucket
if ($manifest) { return $manifest, $bucket }
return $null
}
$buckets = @($null) + @(buckets) # null for main bucket
foreach($bucket in $buckets) {
$manifest = manifest $app $bucket
if($manifest) { return $manifest, $bucket }
}
}