Deduplicate configuration path code
This commit is contained in:
parent
954f120ce2
commit
34586172b5
|
@ -30,10 +30,7 @@ crate fn config_path() -> Result<PathBuf, ShellError> {
|
|||
}
|
||||
|
||||
crate fn write_config(config: &IndexMap<String, Tagged<Value>>) -> Result<(), ShellError> {
|
||||
let location = app_root(AppDataType::UserConfig, &APP_INFO)
|
||||
.map_err(|err| ShellError::string(&format!("Couldn't open config file:\n{}", err)))?;
|
||||
|
||||
let filename = location.join("config.toml");
|
||||
let filename = config_path()?;
|
||||
touch(&filename)?;
|
||||
|
||||
let contents = value_to_toml_value(&Value::Object(Dictionary::new(config.clone())));
|
||||
|
@ -48,10 +45,7 @@ crate fn write_config(config: &IndexMap<String, Tagged<Value>>) -> Result<(), Sh
|
|||
crate fn config(span: impl Into<Span>) -> Result<IndexMap<String, Tagged<Value>>, ShellError> {
|
||||
let span = span.into();
|
||||
|
||||
let location = app_root(AppDataType::UserConfig, &APP_INFO)
|
||||
.map_err(|err| ShellError::string(&format!("Couldn't open config file:\n{}", err)))?;
|
||||
|
||||
let filename = location.join("config.toml");
|
||||
let filename = config_path()?;
|
||||
touch(&filename)?;
|
||||
|
||||
trace!("config file = {}", filename.display());
|
||||
|
|
Loading…
Reference in New Issue
Block a user