forked from asdf-vm/asdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasdf.ps1
31 lines (25 loc) · 751 Bytes
/
asdf.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
$Env:ASDF_DIR = $PSScriptRoot
$_asdf_bin = "$Env:ASDF_DIR/bin"
if ($null -eq $ASDF_DATA_DIR -or $ASDF_DATA_DIR -eq '') {
$_asdf_shims = "${env:HOME}/.asdf/shims"
}
else {
$_asdf_shims = "$ASDF_DATA_DIR/shims"
}
$env:PATH = "${_asdf_bin}:${_asdf_shims}:${env:PATH}"
if ($env:PATH -cnotlike "*${_asdf_bin}*") {
$env:PATH = "_asdf_bin:${env:PATH}"
}
if ($env:PATH -cnotlike "*${_asdf_shims}*") {
$env:PATH = "_asdf_shims:${env:PATH}"
}
Remove-Variable -Force _asdf_bin, _asdf_shims
function asdf {
$asdf = $(Get-Command -CommandType Application asdf).Source
if ($args.Count -gt 0 -and $args[0] -eq 'shell') {
Invoke-Expression $(& $asdf 'export-shell-version' pwsh $args[1..($args.Count + -1)])
}
else {
& $asdf $args
}
}