Skip to content

Commit

Permalink
convert spaces to tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
lukesampson committed Aug 15, 2013
1 parent 01fa31e commit 7382e17
Show file tree
Hide file tree
Showing 17 changed files with 228 additions and 227 deletions.
6 changes: 3 additions & 3 deletions bin/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ iex (new-object net.webclient).downloadstring($core_url)

# prep
if(installed 'scoop') {
write-host "scoop is already installed. run 'scoop update' to get the latest version." -f red
# don't abort if invoked with iex——that would close the PS session
if($myinvocation.commandorigin -eq 'Internal') { return } else { exit 1 }
write-host "scoop is already installed. run 'scoop update' to get the latest version." -f red
# don't abort if invoked with iex——that would close the PS session
if($myinvocation.commandorigin -eq 'Internal') { return } else { exit 1 }
}
$dir = ensure (versiondir 'scoop' 'current')

Expand Down
20 changes: 10 additions & 10 deletions bin/uninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ if($yn -notlike 'y*') { exit }

# run uninstallers if necessary
installed_apps | % {
$app = $_
$version = current_version $app
$dir = versiondir $app $version
$manifest = installed_manifest $app $version
$install = install_info $app $version
$architecture = $install.architecture
$app = $_
$version = current_version $app
$dir = versiondir $app $version
$manifest = installed_manifest $app $version
$install = install_info $app $version
$architecture = $install.architecture

echo "uninstalling $app"
run_uninstaller $manifest $architecture $dir
rm_env_path $manifest $dir
rm_env $manifest
echo "uninstalling $app"
run_uninstaller $manifest $architecture $dir
rm_env_path $manifest $dir
rm_env $manifest
}

if(test-path $scoopdir) {
Expand Down
56 changes: 28 additions & 28 deletions lib/buckets.ps1
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
$bucketsdir = "$scoopdir\buckets"

function bucketdir($name) {
if(!$name) { return relpath "..\bucket" } # main bucket
if(!$name) { return relpath "..\bucket" } # main bucket

"$bucketsdir\$name"
"$bucketsdir\$name"
}

function known_bucket_repo($name) {
$dir = versiondir 'scoop' 'current'
$json = "$dir\buckets.json"
$buckets = gc $json -raw | convertfrom-json -ea stop
$buckets.$name
$dir = versiondir 'scoop' 'current'
$json = "$dir\buckets.json"
$buckets = gc $json -raw | convertfrom-json -ea stop
$buckets.$name
}

function apps_in_bucket($dir) {
gci $dir | ? { $_.name.endswith('.json') } | % { $_ -replace '.json$', '' }
gci $dir | ? { $_.name.endswith('.json') } | % { $_ -replace '.json$', '' }
}

function buckets {
$buckets = @()
if(test-path $bucketsdir) {
gci $bucketsdir | % { $buckets += $_.name }
}
$buckets
$buckets = @()
if(test-path $bucketsdir) {
gci $bucketsdir | % { $buckets += $_.name }
}
$buckets
}

function find_manifest($app) {
@($null) + @(buckets) | % { # null for main bucket
$manifest = manifest $app $_
if($manifest) { return $manifest, $_ }
}
@($null) + @(buckets) | % { # null for main bucket
$manifest = manifest $app $_
if($manifest) { return $manifest, $_ }
}
}

<#
# convert an object to a hashtable
function hashtable($obj) {
$h = @{ }
$obj.psobject.properties | % {
$h[$_.name] = hashtable_val($_.value);
}
return $h
$h = @{ }
$obj.psobject.properties | % {
$h[$_.name] = hashtable_val($_.value);
}
return $h
}
function hashtable_val($obj) {
if($obj -is [object[]]) {
return $_.value | % { hashtable_val($_) }
}
if($obj.gettype().name -eq 'pscustomobject') { # -is is unreliable
return hashtable($obj)
}
return $obj # assume primitive
if($obj -is [object[]]) {
return $_.value | % { hashtable_val($_) }
}
if($obj.gettype().name -eq 'pscustomobject') { # -is is unreliable
return hashtable($obj)
}
return $obj # assume primitive
}
#>
2 changes: 1 addition & 1 deletion lib/commands.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function commands {
}

function command_name($filename) {
$filename.name | sls 'scoop-(.*?)\.ps1$' | % { $_.matches[0].groups[1].value }
$filename.name | sls 'scoop-(.*?)\.ps1$' | % { $_.matches[0].groups[1].value }
}

function exec($cmd, $arguments) {
Expand Down
26 changes: 13 additions & 13 deletions lib/decompress.ps1
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
function 7zip_installed {
try { gcm 7z -ea stop } catch { return $false }
$true
try { gcm 7z -ea stop } catch { return $false }
$true
}

function requires_7zip($fname) {
$fname -match '(\.gz)|(\.tar)|(\.lzma)|(\.7z)$'
$fname -match '(\.gz)|(\.tar)|(\.lzma)|(\.7z)$'
}

function extract_7zip($path, $to, $recurse) {
if(!$recurse) { write-host "extracting..." -nonewline }
$output = 7z x "$path" -o"$to" -y
if($lastexitcode -ne 0) { abort "exit code was $lastexitcode" }
if(!$recurse) { write-host "extracting..." -nonewline }
$output = 7z x "$path" -o"$to" -y
if($lastexitcode -ne 0) { abort "exit code was $lastexitcode" }

# recursively extract files, e.g. for .tar.gz
$output | sls '^Extracting\s+(.*)$' | % {
$fname = $_.matches[0].groups[1].value
if(requires_7zip $fname) { extract_7zip "$to\$fname" $to $true }
}
# recursively extract files, e.g. for .tar.gz
$output | sls '^Extracting\s+(.*)$' | % {
$fname = $_.matches[0].groups[1].value
if(requires_7zip $fname) { extract_7zip "$to\$fname" $to $true }
}

rm $path
if(!$recurse) { write-host "done" }
rm $path
if(!$recurse) { write-host "done" }
}
2 changes: 1 addition & 1 deletion lib/help.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ function help($text) {
}

function my_usage { # gets usage for the calling script
usage (gc $myInvocation.PSCommandPath -raw)
usage (gc $myInvocation.PSCommandPath -raw)
}
58 changes: 29 additions & 29 deletions lib/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,35 @@ function dl_progress($url, $to) {

$wc = new-object net.webclient
register-objectevent $wc downloadprogresschanged progress | out-null
register-objectevent $wc downloadfilecompleted complete | out-null
try {
$wc.downloadfileasync($url, $to)

function is_complete {
try { get-event complete -ea stop; $true } catch { $false }
}

$last_p = -1
while(!(is_complete)) {
$e = wait-event progress
remove-event progress
$p = $e.sourceeventargs.progresspercentage
if($p -ne $last_p) {
[console]::cursorleft = $left
write-host "$p%" -nonewline
$last_p = $p
}
}
remove-event complete
} finally {
remove-event *
unregister-event progress
unregister-event complete
$wc.cancelasync()
$wc.dispose()
}
[console]::cursorleft = $left
register-objectevent $wc downloadfilecompleted complete | out-null
try {
$wc.downloadfileasync($url, $to)

function is_complete {
try { get-event complete -ea stop; $true } catch { $false }
}

$last_p = -1
while(!(is_complete)) {
$e = wait-event progress
remove-event progress
$p = $e.sourceeventargs.progresspercentage
if($p -ne $last_p) {
[console]::cursorleft = $left
write-host "$p%" -nonewline
$last_p = $p
}
}
remove-event complete
} finally {
remove-event *
unregister-event progress
unregister-event complete
$wc.cancelasync()
$wc.dispose()
}
[console]::cursorleft = $left
}

function dl_urls($app, $version, $manifest, $architecture, $dir) {
Expand Down
68 changes: 34 additions & 34 deletions libexec/scoop-bucket.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,52 @@ $usage_add = "usage: scoop bucket add <name> [<repo>]"
$usage_rm = "usage: scoop bucket rm <name>"

function add_bucket($name, $repo) {
if(!$name) { "<name> missing"; $usage_add; exit 1 }
if(!$repo) {
$repo = known_bucket_repo $name
if(!$repo) { "unknown bucket '$name': try specifying <repo>"; $usage_add; exit 1 }
}
if(!$name) { "<name> missing"; $usage_add; exit 1 }
if(!$repo) {
$repo = known_bucket_repo $name
if(!$repo) { "unknown bucket '$name': try specifying <repo>"; $usage_add; exit 1 }
}

$git = try { gcm 'git' -ea stop } catch { $null }
if(!$git) {
abort "git is required for buckets. run 'scoop install git'."
}
$git = try { gcm 'git' -ea stop } catch { $null }
if(!$git) {
abort "git is required for buckets. run 'scoop install git'."
}

$dir = bucketdir $name
if(test-path $dir) {
abort "'$name' bucket already exists. use 'scoop bucket rm $name' to remove it."
}
$dir = bucketdir $name
if(test-path $dir) {
abort "'$name' bucket already exists. use 'scoop bucket rm $name' to remove it."
}

write-host 'checking repo...' -nonewline
git ls-remote $repo 2>&1 > $null
if($lastexitcode -ne 0) {
abort "'$repo' doesn't look like a valid git repository"
}
write-host 'ok'
write-host 'checking repo...' -nonewline
git ls-remote $repo 2>&1 > $null
if($lastexitcode -ne 0) {
abort "'$repo' doesn't look like a valid git repository"
}
write-host 'ok'

ensure $bucketsdir > $null
$dir = ensure $dir
git clone "$repo" "$dir"
success "$name bucket was added successfully"
ensure $bucketsdir > $null
$dir = ensure $dir
git clone "$repo" "$dir"
success "$name bucket was added successfully"
}

function rm_bucket($name) {
if(!$name) { "<name> missing"; $usage_rm; exit 1 }
$dir = bucketdir $name
if(!(test-path $dir)) {
abort "'$name' bucket not found"
}
if(!$name) { "<name> missing"; $usage_rm; exit 1 }
$dir = bucketdir $name
if(!(test-path $dir)) {
abort "'$name' bucket not found"
}

rm $dir -r -force -ea stop
rm $dir -r -force -ea stop
}

function list_buckets {
buckets
buckets
}

switch($cmd) {
"add" { add_bucket $name $repo }
"rm" { rm_bucket $name }
"list" { list_buckets }
default { "scoop bucket: cmd '$cmd' not supported"; my_usage; exit 1 }
"add" { add_bucket $name $repo }
"rm" { rm_bucket $name }
"list" { list_buckets }
default { "scoop bucket: cmd '$cmd' not supported"; my_usage; exit 1 }
}
20 changes: 10 additions & 10 deletions libexec/scoop-cache.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ param($cmd, $app)
. "$psscriptroot\..\lib\help.ps1"

switch($cmd) {
'rm' {
if(!$app) { 'ERROR: <app> missing'; my_usage; exit 1 }
rm "$scoopdir\cache\$app#*"
}
'show' {
gci "$scoopdir\cache" | select name
}
default {
"cache '$cmd' not supported"; my_usage; exit 1
}
'rm' {
if(!$app) { 'ERROR: <app> missing'; my_usage; exit 1 }
rm "$scoopdir\cache\$app#*"
}
'show' {
gci "$scoopdir\cache" | select name
}
default {
"cache '$cmd' not supported"; my_usage; exit 1
}
}

exit 0
Loading

0 comments on commit 7382e17

Please sign in to comment.