mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
Fix the fnm bug of Nushell reloading (#1058)
 Opening a terminal in nvim results in the error shown above.
This commit is contained in:
parent
8b40551de7
commit
096daa436d
1 changed files with 17 additions and 9 deletions
|
@ -23,17 +23,25 @@ export-env {
|
|||
if not (which fnm | is-empty) {
|
||||
fnm-env | load-env
|
||||
|
||||
if (not ($env | default false __fnm_hooked | get __fnm_hooked)) {
|
||||
$env.__fnm_hooked = true
|
||||
$env.config = ($env | default {} config).config
|
||||
$env.config = ($env.config | default {} hooks)
|
||||
$env.config = ($env.config | update hooks ($env.config.hooks | default {} env_change))
|
||||
$env.config = ($env.config | update hooks.env_change ($env.config.hooks.env_change | default [] PWD))
|
||||
$env.config = ($env.config | update hooks.env_change.PWD ($env.config.hooks.env_change.PWD | append { |before, after|
|
||||
$env.config = (
|
||||
$env.config?
|
||||
| default {}
|
||||
| upsert hooks { default {} }
|
||||
| upsert hooks.env_change { default {} }
|
||||
| upsert hooks.env_change.PWD { default [] }
|
||||
)
|
||||
let __fnm_hooked = (
|
||||
$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,
|
||||
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); (fnm-env | load-env)
|
||||
}
|
||||
}
|
||||
}))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue