Skip to content

Commit

Permalink
Merge pull request #42 from fpco/create-config-dir
Browse files Browse the repository at this point in the history
Create config dir if missing
  • Loading branch information
snoyberg authored Aug 1, 2024
2 parents 0f2a5ad + 7ae6170 commit 62b4e3b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/cosmos/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ impl CosmosConfig {
let s = toml::to_string_pretty(&self.inner)
.map_err(|source| CosmosConfigError::TomlSerialization { source })?;
let path = path.as_ref();
if let Some(parent) = path.parent() {
fs_err::create_dir_all(parent).map_err(|source| CosmosConfigError::ConfigWrite {
source,
path: path.to_owned(),
})?;
}
fs_err::write(path, s).map_err(|source| CosmosConfigError::ConfigWrite {
source,
path: path.to_owned(),
Expand Down

0 comments on commit 62b4e3b

Please sign in to comment.