Skip to content

Commit

Permalink
Clean up handling of working directory
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Jul 18, 2022
1 parent 617a9cd commit 135771d
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions tools/release-operator/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,11 @@ impl Crate {
fn submit(&self, token: &SecUtf8, dry_run: bool) -> anyhow::Result<()> {
log::info!("{self} publishing new version");

let current_dir = std::env::current_dir()
.context("determine current working directory")?;
std::env::set_current_dir(&self.path)
.context("switch working directory to the crate in scope")?;

let mut command = Command::new("cargo");
command.arg("publish").args(["--token", token.unsecure()]);
command
.arg("publish")
.args(["--token", token.unsecure()])
.current_dir(&self.path);

if dry_run {
command.arg("--dry-run");
Expand All @@ -177,9 +175,6 @@ impl Crate {
}
}

std::env::set_current_dir(current_dir)
.context("reset working directory")?;

Ok(())
}
}
Expand Down

0 comments on commit 135771d

Please sign in to comment.