Run ENV_CONVERSIONS whenever it's modified (#14591)

- this PR should close #14514

# Description
Makes updates to `$env.ENV_CONVERSIONS` take effect immediately.

# User-Facing Changes
No breaking change, `$env.ENV_CONVERSIONS` can be set and its effect
used in the same file.

# Tests + Formatting

- 🟢 toolkit fmt
- 🟢 toolkit clippy
- 🟢 toolkit test
- 🟢 toolkit test stdlib

# After Submitting
N/A
This commit is contained in:
Bahex
2024-12-25 16:37:24 +03:00
committed by GitHub
parent 45ff964cbd
commit 1b01598840
4 changed files with 118 additions and 65 deletions

View File

@@ -190,6 +190,16 @@ fn env_var_case_insensitive() {
assert!(actual.out.contains("222"));
}
#[test]
fn env_conversion_on_assignment() {
let actual = nu!(r#"
$env.FOO = "bar:baz:quox"
$env.ENV_CONVERSIONS = { FOO: { from_string: {|| split row ":"} } }
$env.FOO | to nuon
"#);
assert_eq!(actual.out, "[bar, baz, quox]");
}
#[test]
fn std_log_env_vars_are_not_overridden() {
let actual = nu_with_std!(