Skip to content

Commit

Permalink
cli: Fix altering user-provided lib names (#3467)
Browse files Browse the repository at this point in the history
  • Loading branch information
acheroncrypto authored Jan 8, 2025
1 parent 7b6c2b3 commit 0922dc3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- cli: Ignore non semver solana/agave releases to avoid panic ([#3432](https://github.com/coral-xyz/anchor/pull/3432)).
- ts: Fix loading programs with numbers in their names using `workspace` ([#3450](https://github.com/coral-xyz/anchor/pull/3450)).
- lang: Remove a potential panic while getting the IDL in `declare_program!` ([#3458](https://github.com/coral-xyz/anchor/pull/3458)).
- cli: Fix altering user-provided lib names ([#3467](https://github.com/coral-xyz/anchor/pull/3467)).

### Breaking

Expand Down
23 changes: 7 additions & 16 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,15 @@ impl Manifest {
}

pub fn lib_name(&self) -> Result<String> {
if self.lib.is_some() && self.lib.as_ref().unwrap().name.is_some() {
Ok(self
.lib
.as_ref()
.unwrap()
.name
.as_ref()
.unwrap()
.to_string()
.to_snake_case())
} else {
Ok(self
match &self.lib {
Some(cargo_toml::Product {
name: Some(name), ..
}) => Ok(name.to_owned()),
_ => self
.package
.as_ref()
.ok_or_else(|| anyhow!("package section not provided"))?
.name
.to_string()
.to_snake_case())
.ok_or_else(|| anyhow!("package section not provided"))
.map(|pkg| pkg.name.to_snake_case()),
}
}

Expand Down

0 comments on commit 0922dc3

Please sign in to comment.