Make it startable from playwright and also isolate (#5016)
Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
use etcetera::{choose_app_strategy, AppStrategy, AppStrategyArgs};
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub struct Paths;
|
||||
|
||||
impl Paths {
|
||||
fn get_dir(dir_type: DirType) -> PathBuf {
|
||||
if let Ok(test_root) = std::env::var("GOOSE_PATH_ROOT") {
|
||||
let base = PathBuf::from(test_root);
|
||||
match dir_type {
|
||||
DirType::Config => base.join("config"),
|
||||
DirType::Data => base.join("data"),
|
||||
DirType::State => base.join("state"),
|
||||
}
|
||||
} else {
|
||||
let strategy = choose_app_strategy(AppStrategyArgs {
|
||||
top_level_domain: "Block".to_string(),
|
||||
author: "Block".to_string(),
|
||||
app_name: "goose".to_string(),
|
||||
})
|
||||
.expect("goose requires a home dir");
|
||||
|
||||
match dir_type {
|
||||
DirType::Config => strategy.config_dir(),
|
||||
DirType::Data => strategy.data_dir(),
|
||||
DirType::State => strategy.state_dir().unwrap_or(strategy.data_dir()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn config_dir() -> PathBuf {
|
||||
Self::get_dir(DirType::Config)
|
||||
}
|
||||
|
||||
pub fn data_dir() -> PathBuf {
|
||||
Self::get_dir(DirType::Data)
|
||||
}
|
||||
|
||||
pub fn state_dir() -> PathBuf {
|
||||
Self::get_dir(DirType::State)
|
||||
}
|
||||
|
||||
pub fn in_state_dir(subpath: &str) -> PathBuf {
|
||||
Self::state_dir().join(subpath)
|
||||
}
|
||||
|
||||
pub fn in_config_dir(subpath: &str) -> PathBuf {
|
||||
Self::config_dir().join(subpath)
|
||||
}
|
||||
|
||||
pub fn in_data_dir(subpath: &str) -> PathBuf {
|
||||
Self::data_dir().join(subpath)
|
||||
}
|
||||
}
|
||||
|
||||
enum DirType {
|
||||
Config,
|
||||
Data,
|
||||
State,
|
||||
}
|
||||
Reference in New Issue
Block a user