Skip to content

Commit

Permalink
fix(clean): Better detect what we can't clean
Browse files Browse the repository at this point in the history
This includes a more appropriate error message.
  • Loading branch information
epage committed Oct 25, 2017
1 parent 80468b9 commit 78bbfc3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/bin/cobalt/build.rs
Expand Up @@ -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(())
}
Expand Down
2 changes: 1 addition & 1 deletion tests/cli.rs
Expand Up @@ -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();
Expand Down

0 comments on commit 78bbfc3

Please sign in to comment.