1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00

fix(fnm): Automatic version switching failed. (#1064)

![image](https://github.com/user-attachments/assets/c31f7a3a-e312-4773-bb25-5e3c10747bd6)
This commit is contained in:
ziboh 2025-03-07 21:09:20 +08:00 committed by GitHub
parent c517cd0075
commit 10fc3797e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
}
}
}
)
}
}
}