Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

target/deploy dir check #2504

Merged
merged 2 commits into from
May 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3051,23 +3051,31 @@ fn clean(cfg_override: &ConfigOverride) -> Result<()> {
let target_dir = cfg_parent.join("target");
let deploy_dir = target_dir.join("deploy");

for entry in fs::read_dir(target_dir)? {
let path = entry?.path();
if path.is_dir() && path != deploy_dir {
fs::remove_dir_all(&path)
.map_err(|e| anyhow!("Could not remove directory {}: {}", path.display(), e))?;
} else if path.is_file() {
fs::remove_file(&path)
.map_err(|e| anyhow!("Could not remove file {}: {}", path.display(), e))?;
if target_dir.exists() {
for entry in fs::read_dir(target_dir)? {
let path = entry?.path();
if path.is_dir() && path != deploy_dir {
fs::remove_dir_all(&path)
.map_err(|e| anyhow!("Could not remove directory {}: {}", path.display(), e))?;
} else if path.is_file() {
fs::remove_file(&path)
.map_err(|e| anyhow!("Could not remove file {}: {}", path.display(), e))?;
}
}
} else {
println!("skipping target directory: not found")
}

for file in fs::read_dir(deploy_dir)? {
let path = file?.path();
if path.extension() != Some(&OsString::from("json")) {
fs::remove_file(&path)
.map_err(|e| anyhow!("Could not remove file {}: {}", path.display(), e))?;
if deploy_dir.exists() {
for file in fs::read_dir(deploy_dir)? {
let path = file?.path();
if path.extension() != Some(&OsString::from("json")) {
fs::remove_file(&path)
.map_err(|e| anyhow!("Could not remove file {}: {}", path.display(), e))?;
}
}
} else {
println!("skipping deploy directory: not found")
}

Ok(())
Expand Down