Allow "export-env" parsing in modules (#6382)

* Allow "export-env" parsing in modules

* Fmt

* Add test for importing module's environment
This commit is contained in:
Jakub Žádník
2022-08-23 10:45:17 +03:00
committed by GitHub
parent 839b264261
commit d97975e9fa
4 changed files with 126 additions and 12 deletions

View File

@ -345,3 +345,21 @@ fn module_nested_imports_in_dirs_prefixed() {
assert_eq!(actual.out, "bar");
})
}
#[test]
fn module_eval_export_env() {
Playground::setup("module_eval_export_env", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContentToBeTrimmed(
"spam.nu",
r#"
export-env { let-env FOO = 'foo' }
"#,
)]);
let inp = &[r#"source spam.nu"#, r#"$env.FOO"#];
let actual = nu!(cwd: dirs.test(), pipeline(&inp.join("; ")));
assert_eq!(actual.out, "foo");
})
}