Add automatic change directory (#1496)

* Allow automatic cd in cli mode

* Set correct priority for auto-cd and add test
This commit is contained in:
Jonathan Turner
2020-03-18 07:13:38 +13:00
committed by GitHub
parent 0d244a9701
commit 1ec2ec72b5
2 changed files with 47 additions and 4 deletions

View File

@ -20,6 +20,25 @@ fn shows_error_for_command_not_found() {
assert!(actual.contains("Command not found"));
}
#[test]
fn automatically_change_directory() {
use nu_test_support::playground::Playground;
Playground::setup("cd_test_5_1", |dirs, sandbox| {
sandbox.within("autodir").mkdir("bar");
let actual = nu!(
cwd: dirs.test(),
r#"
autodir
pwd | echo $it
"#
);
assert!(actual.ends_with("autodir"));
})
}
mod it_evaluation {
use super::nu;
use nu_test_support::fs::Stub::{EmptyFile, FileWithContent, FileWithContentToBeTrimmed};