mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2026-07-09 08:51:17 +00:00
6d9bca805f
* makes changes to almost all main repo files to be in accordance with .editorconfig * some files in "test\fixtures\..." were left alone to avoid breaking tests * NOTE: whitespace changes *only* (`git diff -b` shows no changes)
38 lines
886 B
PowerShell
38 lines
886 B
PowerShell
function command_files {
|
|
(gci (relpath '..\libexec')) `
|
|
+ (gci "$scoopdir\shims") `
|
|
| where { $_.name -match 'scoop-.*?\.ps1$' }
|
|
}
|
|
|
|
function commands {
|
|
command_files | % { command_name $_ }
|
|
}
|
|
|
|
function command_name($filename) {
|
|
$filename.name | sls 'scoop-(.*?)\.ps1$' | % { $_.matches[0].groups[1].value }
|
|
}
|
|
|
|
function command_path($cmd) {
|
|
$cmd_path = relpath "..\libexec\scoop-$cmd.ps1"
|
|
|
|
# built in commands
|
|
if (!(Test-Path $cmd_path)) {
|
|
# get path from shim
|
|
$shim_path = "$scoopdir\shims\scoop-$cmd.ps1"
|
|
$line = ((gc $shim_path) | where { $_.startswith('$path') })
|
|
if($line) {
|
|
iex -command "$line"
|
|
$cmd_path = $path
|
|
}
|
|
else { $cmd_path = $shim_path }
|
|
}
|
|
|
|
$cmd_path
|
|
}
|
|
|
|
function exec($cmd, $arguments) {
|
|
$cmd_path = command_path $cmd
|
|
|
|
& $cmd_path @arguments
|
|
}
|