Skip to content

Commit

Permalink
feat: cleanup after publishing packages (#3259)
Browse files Browse the repository at this point in the history
Removes `.hub` directory after publishing packages
to the Hub when using both **cdk** or **smdk**.
  • Loading branch information
EstebanBorai committed May 15, 2023
1 parent 7957551 commit db1e4ab
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
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)?;
}

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

0 comments on commit db1e4ab

Please sign in to comment.