Skip to content

Commit

Permalink
feat: create data_local_dir function to ensure consistent location
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed Apr 23, 2024
1 parent 1fd7743 commit 2f68a0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 1 addition & 3 deletions cmd/soroban-cli/src/commands/cache/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ pub struct Cmd {}

impl Cmd {
pub fn run(&self) -> Result<(), Error> {
let binding = data::project_dir()?;
let dir = binding.data_dir();
println!("{}", dir.to_string_lossy());
println!("{:?}", data::data_local_dir()?);
Ok(())
}
}
11 changes: 8 additions & 3 deletions cmd/soroban-cli/src/commands/config/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,22 @@ pub fn project_dir() -> Result<directories::ProjectDirs, Error> {
|_| ProjectDirs::from("com", "stellar", "stellar-cli"),
|data_home| ProjectDirs::from_path(std::path::PathBuf::from(data_home)),
)
.ok_or(Error::FiledToFindProjectDirs)
.ok_or(Error::FailedToFindProjectDirs)
}

#[allow(clippy::module_name_repetitions)]
pub fn data_local_dir() -> Result<std::path::PathBuf, Error> {
Ok(project_dir()?.data_local_dir().to_path_buf())
}

pub fn actions_dir() -> Result<std::path::PathBuf, Error> {
let dir = project_dir()?.data_local_dir().join("actions");
let dir = data_local_dir()?.join("actions");
std::fs::create_dir_all(&dir)?;
Ok(dir)
}

pub fn spec_dir() -> Result<std::path::PathBuf, Error> {
let dir = project_dir()?.data_local_dir().join("spec");
let dir = data_local_dir()?.join("spec");
std::fs::create_dir_all(&dir)?;
Ok(dir)
}
Expand Down

0 comments on commit 2f68a0d

Please sign in to comment.