direnv: simplify, work around nushell/nushell#14112

nushell 0.99 does not like early returns in hooks. So, what if we just
didn't? Rewrite the entire hook to work as one single pipeline.
This commit is contained in:
K900 2024-10-17 22:10:39 +03:00 committed by Robert Helgesson
parent e78cbb2027
commit 1834304bc3
Failed to generate hash of commit

View file

@ -162,28 +162,20 @@ in {
$env.config.hooks.pre_prompt? $env.config.hooks.pre_prompt?
| default [] | default []
| append {|| | append {||
let direnv = ( ${direnvWrapped}
${direnvWrapped} | from json --strict
| from json --strict | default {}
| default {}
)
if ($direnv | is-empty) {
return
}
$direnv
| items {|key, value| | items {|key, value|
{ let value = do (
key: $key $env.ENV_CONVERSIONS?
value: (do ( | default {}
$env.ENV_CONVERSIONS? | get -i $key
| default {} | get -i from_string
| get -i $key | default {|x| $x}
| get -i from_string ) $value
| default {|x| $x} return [ $key $value ]
) $value)
}
} }
| transpose -ird | into record
| load-env | load-env
} }
) )