mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 06:30:08 +02:00
make cd
, cp
, ls
, mv
, open
and rm
automatically strip ansi codes (#6220)
* make `cd`, `cp`, `ls`, `mv`, `open` and `rm` automatically strip ansi escape code * fix nu-cli test * fix nu-cli test 2 * fix nu-cli test 3 * remove `include-ansi` arg * fix test
This commit is contained in:
@ -331,3 +331,16 @@ fn copy_identical_file() {
|
||||
assert!(actual.err.contains("Copy aborted"));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn copy_ignores_ansi() {
|
||||
Playground::setup("cp_test_16", |_dirs, sandbox| {
|
||||
sandbox.with_files(vec![EmptyFile("test.txt")]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: sandbox.cwd(),
|
||||
"ls | find test | get name | cp $in.0 success.txt; ls | find success | get name | ansi strip | get 0",
|
||||
);
|
||||
assert_eq!(actual.out, "success.txt");
|
||||
});
|
||||
}
|
||||
|
@ -538,3 +538,24 @@ fn list_directory_contains_invalid_utf8() {
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn list_ignores_ansi() {
|
||||
Playground::setup("ls_test_ansi", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![
|
||||
EmptyFile("los.txt"),
|
||||
EmptyFile("tres.txt"),
|
||||
EmptyFile("amigos.txt"),
|
||||
EmptyFile("arepas.clu"),
|
||||
]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls | find .txt | each { ls $in.name }
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.err.is_empty());
|
||||
})
|
||||
}
|
||||
|
@ -360,3 +360,18 @@ fn does_not_error_when_some_file_is_moving_into_itself() {
|
||||
assert!(expected.exists());
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mv_ignores_ansi() {
|
||||
Playground::setup("mv_test_ansi", |_dirs, sandbox| {
|
||||
sandbox.with_files(vec![EmptyFile("test.txt")]);
|
||||
let actual = nu!(
|
||||
cwd: sandbox.cwd(),
|
||||
r#"
|
||||
ls | find test | mv $in.0.name success.txt; ls | $in.0.name
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "success.txt");
|
||||
})
|
||||
}
|
||||
|
@ -267,3 +267,19 @@ fn test_open_block_command() {
|
||||
|
||||
assert_eq!(actual.out, "abcd")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn open_ignore_ansi() {
|
||||
Playground::setup("open_test_ansi", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![EmptyFile("nu.zion.txt")]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
ls | find nu.zion | get 0 | get name | open $in
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.err.is_empty());
|
||||
})
|
||||
}
|
||||
|
@ -324,3 +324,16 @@ fn removes_files_with_case_sensitive_glob_matches_by_default() {
|
||||
assert!(skipped_path.exists());
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_ignores_ansi() {
|
||||
Playground::setup("rm_test_ansi", |_dirs, sandbox| {
|
||||
sandbox.with_files(vec![EmptyFile("test.txt")]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: sandbox.cwd(),
|
||||
"ls | find test | get name | rm $in.0; ls",
|
||||
);
|
||||
assert!(actual.out.is_empty());
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user