forked from ScoopInstaller/Scoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuckets.ps1
44 lines (36 loc) · 1.01 KB
/
buckets.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
$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"
gc $json -raw | convertfrom-json -ea stop
}
function known_bucket_repo($name) {
$buckets = known_bucket_repos
$buckets.$name
}
function apps_in_bucket($dir) {
gci $dir | ? { $_.name.endswith('.json') } | % { $_ -replace '.json$', '' }
}
function buckets {
$buckets = @()
if(test-path $bucketsdir) {
gci $bucketsdir | % { $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 }
}
}