chore(solc): create artifacts folder on output (#1772)
This commit is contained in:
parent
7439dea0bb
commit
7b87c44a54
|
@ -10,7 +10,7 @@ use crate::{
|
|||
error::Result,
|
||||
sourcemap::{SourceMap, SyntaxError},
|
||||
sources::VersionedSourceFile,
|
||||
utils, HardhatArtifact, ProjectPathsConfig, SolFilesCache, SolcError,
|
||||
utils, HardhatArtifact, ProjectPathsConfig, SolFilesCache, SolcError, SolcIoError,
|
||||
};
|
||||
use ethers_core::{abi::Abi, types::Bytes};
|
||||
use semver::Version;
|
||||
|
@ -577,6 +577,11 @@ pub trait ArtifactOutput {
|
|||
ctx: OutputContext,
|
||||
) -> Result<Artifacts<Self::Artifact>> {
|
||||
let mut artifacts = self.output_to_artifacts(contracts, sources, ctx);
|
||||
fs::create_dir_all(&layout.artifacts).map_err(|err| {
|
||||
error!(dir=?layout.artifacts, "Failed to create artifacts folder");
|
||||
SolcIoError::new(err, &layout.artifacts)
|
||||
})?;
|
||||
|
||||
artifacts.join_all(&layout.artifacts);
|
||||
artifacts.write_all()?;
|
||||
|
||||
|
|
|
@ -468,6 +468,17 @@ mod tests {
|
|||
assert!(path.parent().unwrap().is_dir());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_create_parent_dirs_versioned() {
|
||||
let tmp_dir = tempdir("out").unwrap();
|
||||
let path = tmp_dir.path().join("IVersioned.sol/IVersioned.0.8.16.json");
|
||||
create_parent_dir_all(&path).unwrap();
|
||||
assert!(path.parent().unwrap().is_dir());
|
||||
let path = tmp_dir.path().join("IVersioned.sol/IVersioned.json");
|
||||
create_parent_dir_all(&path).unwrap();
|
||||
assert!(path.parent().unwrap().is_dir());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_determine_local_paths() {
|
||||
assert!(is_local_source_name(&[""], "./local/contract.sol"));
|
||||
|
|
Loading…
Reference in New Issue