mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-09-11 13:45:56 +03:00
Use Existing Path Env Var for FNM (#632)
The module for `fnm` did not set the path for Windows correctly. I fixed it by searching for the used `Path` variable (or `PATH`) and use that instead. Works now better on Windows without breaking other OSes.
This commit is contained in:
parent
c9d63946ec
commit
85da8c2fb5
@ -1,20 +1,22 @@
|
|||||||
export-env {
|
export-env {
|
||||||
def fnm-env [] {
|
def fnm-env [] {
|
||||||
mut env_vars = {}
|
mut env_vars = {}
|
||||||
let pwsh_vars = (^fnm env --shell power-shell)
|
let pwsh_vars = (
|
||||||
let var_table = ($pwsh_vars
|
^fnm env --shell power-shell |
|
||||||
| lines
|
lines |
|
||||||
| parse "$env:{key} = \"{value}\""
|
parse "$env:{key} = \"{value}\""
|
||||||
)
|
)
|
||||||
for v in $var_table {
|
|
||||||
mut value: any = null
|
# fnm-prefixed vars
|
||||||
if ($v.key | str downcase) == 'path' {
|
for v in ($pwsh_vars | range 1..) {
|
||||||
$value = ($v.value | split row (char esep))
|
$env_vars = ($env_vars | insert $v.key $v.value)
|
||||||
} else {
|
|
||||||
$value = $v.value
|
|
||||||
}
|
|
||||||
$env_vars = ($env_vars | insert $v.key $value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# path
|
||||||
|
let env_used_path = ($env | columns | where {str downcase | $in == "path"} | get 0)
|
||||||
|
let path_value = ($pwsh_vars | get 0.value | split row (char esep))
|
||||||
|
$env_vars = ($env_vars | insert $env_used_path $path_value)
|
||||||
|
|
||||||
return $env_vars
|
return $env_vars
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user