From 23c356ce3823272dd96e70f5453dea732c182d7b Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 4 Dec 2021 18:27:30 +0100 Subject: [PATCH] feat(solc): add clean up function (#649) --- ethers-solc/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ethers-solc/src/lib.rs b/ethers-solc/src/lib.rs index a1e2565d..374f0211 100644 --- a/ethers-solc/src/lib.rs +++ b/ethers-solc/src/lib.rs @@ -364,6 +364,17 @@ impl Project { self.ignored_error_codes.clone(), )) } + + /// Removes the project's artifacts and cache file + pub fn cleanup(&self) -> Result<()> { + if self.paths.cache.exists() { + std::fs::remove_dir_all(&self.paths.cache)?; + } + if self.paths.artifacts.exists() { + std::fs::remove_dir_all(&self.paths.artifacts)?; + } + Ok(()) + } } fn apply_mappings(sources: Sources, mut mappings: HashMap) -> Sources {