File tree 1 file changed +18
-14
lines changed
1 file changed +18
-14
lines changed Original file line number Diff line number Diff line change @@ -21,23 +21,27 @@ export-env {
21
21
}
22
22
23
23
if not (which fnm | is-empty ) {
24
- if ((" __fnm_hooked" in $env ) and ($env .__fnm_hooked | describe ) == " string" ) {
25
- $env .__fnm_hooked = false
26
- } else {
27
- fnm-env | load-env
28
- }
24
+ fnm-env | load-env
29
25
30
- if (not ($env | default false __fnm_hooked | get __fnm_hooked )) {
31
- $env .__fnm_hooked = true
32
- $env .config = ($env | default {} config ).config
33
- $env .config = ($env .config | default {} hooks )
34
- $env .config = ($env .config | update hooks ($env .config.hooks | default {} env_change ))
35
- $env .config = ($env .config | update hooks.env_change ($env .config.hooks.env_change | default [] PWD ))
36
- $env .config = ($env .config | update hooks.env_change.PWD ($env .config.hooks.env_change.PWD | append { |before , after |
26
+ $env .config = (
27
+ $env .config ?
28
+ | default {}
29
+ | upsert hooks { default {} }
30
+ | upsert hooks.env_change { default {} }
31
+ | upsert hooks.env_change.PWD { default [] }
32
+ )
33
+ let __fnm_hooked = (
34
+ $env .config.hooks.env_change.PWD | any { try { get __fnm_hook } catch { false } }
35
+ )
36
+ if not $__fnm_hooked {
37
+ $env .config.hooks.env_change.PWD = ($env .config.hooks.env_change.PWD | append {
38
+ __fnm_hook : true ,
39
+ code : {|before , after |
37
40
if (' FNM_DIR' in $env ) and ([.nvmrc .node-version ] | path exists | any { |it | $it }) {
38
- (^ fnm use ); (fnm-env | load-env )
41
+ (^ fnm use ); (fnm-env | load-env )
42
+ }
39
43
}
40
- }))
44
+ })
41
45
}
42
46
}
43
47
}
You can’t perform that action at this time.
0 commit comments