Skip to content

Commit fd92f8c

Browse files
committed
refactor(forge build): update cache_local_signatures to accept an optional cache_dir
No more need to unwrap the option value returned foundry's `config` crate
1 parent a70c367 commit fd92f8c

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

crates/cli/src/utils/cmd.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,14 @@ pub async fn print_traces(
440440

441441
/// Traverse the artifacts in the project to generate local signatures and merge them into the cache
442442
/// file.
443-
pub fn cache_local_signatures(output: &ProjectCompileOutput, cache_dir: &Path) -> Result<()> {
443+
pub fn cache_local_signatures(
444+
output: &ProjectCompileOutput,
445+
cache_dir: Option<PathBuf>,
446+
) -> Result<()> {
447+
let Some(cache_dir) = cache_dir else {
448+
eyre::bail!("Failed to get `cache_dir` to generate local signatures.");
449+
};
450+
444451
let path = cache_dir.join("signatures");
445452
let mut signatures = SignaturesCache::load(&path);
446453
for (_, artifact) in output.artifacts() {

crates/forge/src/cmd/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl BuildArgs {
104104
let output = compiler.compile(&project)?;
105105

106106
// Cache project selectors.
107-
cache_local_signatures(&output, &Config::foundry_cache_dir().unwrap())?;
107+
cache_local_signatures(&output, Config::foundry_cache_dir())?;
108108

109109
if format_json && !self.names && !self.sizes {
110110
sh_println!("{}", serde_json::to_string_pretty(&output.output())?)?;

crates/forge/src/cmd/selectors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl SelectorsSubcommands {
9595
// compile the project to get the artifacts/abis
9696
let project = build_args.project()?;
9797
let outcome = ProjectCompiler::new().quiet(true).compile(&project)?;
98-
cache_local_signatures(&outcome, &Config::foundry_cache_dir().unwrap())?
98+
cache_local_signatures(&outcome, Config::foundry_cache_dir())?;
9999
}
100100
Self::Upload { contract, all, project_paths } => {
101101
let build_args = BuildOpts {

0 commit comments

Comments
 (0)