mirror of
https://github.com/sagiegurari/duckscript
synced 2024-10-14 11:53:05 +00:00
fix: Command rm
remove file with flag -r
This commit is contained in:
parent
3877712774
commit
1d6cf15bf2
|
@ -49,7 +49,7 @@ impl Command for CommandImpl {
|
||||||
let result = if !path.exists() {
|
let result = if !path.exists() {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else if path.is_file() {
|
} else if path.is_file() {
|
||||||
fs::remove_file(&arguments[0])
|
fs::remove_file(&path)
|
||||||
} else if recursive {
|
} else if recursive {
|
||||||
fs::remove_dir_all(&path)
|
fs::remove_dir_all(&path)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -56,6 +56,22 @@ fn run_path_is_file() {
|
||||||
assert!(!path.exists());
|
assert!(!path.exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn run_path_is_file_and_with_flag() {
|
||||||
|
let path = Path::new("./target/_duckscript/rm/file_with_flag.txt");
|
||||||
|
let result = ensure_exists("./target/_duckscript/rm/file_with_flag.txt");
|
||||||
|
assert!(result.is_ok());
|
||||||
|
assert!(path.exists());
|
||||||
|
|
||||||
|
test::run_script_and_validate(
|
||||||
|
vec![create("")],
|
||||||
|
"out = rm -r ./target/_duckscript/rm/file_with_flag.txt",
|
||||||
|
CommandValidation::Match("out".to_string(), "true".to_string()),
|
||||||
|
);
|
||||||
|
|
||||||
|
assert!(!path.exists());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn run_path_recursive() {
|
fn run_path_recursive() {
|
||||||
let path = Path::new("./target/_duckscript/rm/recursive/file.txt");
|
let path = Path::new("./target/_duckscript/rm/recursive/file.txt");
|
||||||
|
|
Loading…
Reference in a new issue