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

[Merged by Bors] - feat: cleanup after publishing packages #3259

Closed
Show file tree
Hide file tree
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
22 changes: 17 additions & 5 deletions crates/cdk/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ impl PublishCmd {
package_info.package_path().to_string_lossy()
);

if hubdir.exists() {
tracing::warn!("Removing directory at {:?}", hubdir);
remove_dir_all(&hubdir)?;
}

self.cleanup(&package_info)?;
build_connector(&package_info, BuildOpts::with_release(opt.release.as_str()))?;
init_package_template(&package_info, &self.readme)?;
check_package_meta_visiblity(&package_info)?;
Expand Down Expand Up @@ -106,6 +102,22 @@ impl PublishCmd {
}
}

if !self.pack {
self.cleanup(&package_info)?;
}
Comment on lines +105 to +107
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of calling separately, we skip running the cleanup if the --pack argument is not present.
This way we always cleanup unless specified.


Ok(())
}

pub fn cleanup(&self, package_info: &PackageInfo) -> Result<()> {
let hubdir = package_info.package_relative_path(DEF_HUB_INIT_DIR);

if hubdir.exists() {
// Delete the `.hub` directory if already exists
tracing::warn!("Removing directory at {:?}", hubdir);
remove_dir_all(&hubdir)?;
}

Ok(())
}
}
Expand Down
22 changes: 17 additions & 5 deletions crates/smartmodule-development-kit/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ impl PublishCmd {
let package_info = PackageInfo::from_options(&opt)?;
let hubdir = package_info.package_relative_path(DEF_HUB_INIT_DIR);

if hubdir.exists() {
// Delete the `.hub` directory if already exists
tracing::warn!("Removing directory at {:?}", hubdir);
remove_dir_all(&hubdir)?;
}
self.cleanup(&package_info)?;

init_package_template(&package_info)?;
check_package_meta_visiblity(&package_info)?;
Expand Down Expand Up @@ -85,6 +81,22 @@ impl PublishCmd {
}
}

if !self.pack {
self.cleanup(&package_info)?;
}

Ok(())
}

fn cleanup(&self, package_info: &PackageInfo) -> Result<()> {
let hubdir = package_info.package_relative_path(DEF_HUB_INIT_DIR);

if hubdir.exists() {
// Delete the `.hub` directory if already exists
tracing::warn!("Removing directory at {:?}", hubdir);
remove_dir_all(&hubdir)?;
}

Ok(())
}
}
Expand Down
Loading