fix(clean): Better detect what we can't clean

This includes a more appropriate error message.
This commit is contained in:
Ed Page 2017-10-24 19:12:43 -06:00
parent 80468b9f5d
commit 78bbfc3eb3
2 changed files with 5 additions and 5 deletions

View file

@ -72,14 +72,14 @@ pub fn clean_command(matches: &clap::ArgMatches) -> Result<()> {
.dest
.canonicalize()
.unwrap_or_else(|_| path::PathBuf::new());
if cwd == destdir {
bail!("Destination directory is same as current directory. \
if cwd.starts_with(&destdir) {
bail!("Attempting to delete current directory, \
Cancelling the operation");
}
fs::remove_dir_all(&config.dest)?;
fs::remove_dir_all(&destdir)?;
info!("directory \"{:?}\" removed", &config.dest);
info!("directory \"{:?}\" removed", &destdir);
Ok(())
}

View file

@ -169,7 +169,7 @@ pub fn clean_warning() {
.fails_with(1)
.stderr()
.contains(
"Destination directory is same as current directory. Cancelling the \
"Attempting to delete current directory, Cancelling the \
operation",
)
.unwrap();