mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
fix(fnm): Automatic version switching failed. (#1064)

This commit is contained in:
parent
c517cd0075
commit
10fc3797e0
1 changed files with 47 additions and 47 deletions
|
@ -2,9 +2,7 @@ export-env {
|
|||
def fnm-env [] {
|
||||
mut env_vars = {}
|
||||
let pwsh_vars = (
|
||||
^fnm env --shell power-shell |
|
||||
lines |
|
||||
parse "$env:{key} = \"{value}\""
|
||||
^fnm env --shell power-shell | lines | parse "$env:{key} = \"{value}\""
|
||||
)
|
||||
|
||||
# fnm-prefixed vars
|
||||
|
@ -34,14 +32,16 @@ export-env {
|
|||
$env.config.hooks.env_change.PWD | any { try { get __fnm_hook } catch { false } }
|
||||
)
|
||||
if not $__fnm_hooked {
|
||||
$env.config.hooks.env_change.PWD = ($env.config.hooks.env_change.PWD | append {
|
||||
__fnm_hook: true,
|
||||
$env.config.hooks.env_change.PWD = (
|
||||
$env.config.hooks.env_change.PWD | append {
|
||||
__fnm_hook: true
|
||||
code: {|before, after|
|
||||
if ('FNM_DIR' in $env) and ([.nvmrc .node-version] | path exists | any {|it| $it }) {
|
||||
(^fnm use); (fnm-env | load-env)
|
||||
}
|
||||
}
|
||||
})
|
||||
^fnm use
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue