mirror of
https://github.com/nushell/nushell
synced 2024-11-15 01:17:07 +00:00
Create config directory if it does not exist (#625)
Signed-off-by: nibon7 <nibon7@163.com>
This commit is contained in:
parent
56ae07adb9
commit
15b0424d73
1 changed files with 15 additions and 7 deletions
22
src/main.rs
22
src/main.rs
|
@ -265,15 +265,23 @@ fn main() -> Result<()> {
|
||||||
// Load config startup file
|
// Load config startup file
|
||||||
if let Some(mut config_path) = nu_path::config_dir() {
|
if let Some(mut config_path) = nu_path::config_dir() {
|
||||||
config_path.push("nushell");
|
config_path.push("nushell");
|
||||||
config_path.push("config.nu");
|
|
||||||
|
|
||||||
if config_path.exists() {
|
// Create config directory if it does not exist
|
||||||
// FIXME: remove this message when we're ready
|
if !config_path.exists() {
|
||||||
println!("Loading config from: {:?}", config_path);
|
if let Err(err) = std::fs::create_dir_all(&config_path) {
|
||||||
let config_filename = config_path.to_string_lossy().to_owned();
|
eprintln!("Failed to create config directory: {}", err);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
config_path.push("config.nu");
|
||||||
|
|
||||||
if let Ok(contents) = std::fs::read_to_string(&config_path) {
|
if config_path.exists() {
|
||||||
eval_source(&mut engine_state, &mut stack, &contents, &config_filename);
|
// FIXME: remove this message when we're ready
|
||||||
|
println!("Loading config from: {:?}", config_path);
|
||||||
|
let config_filename = config_path.to_string_lossy().to_owned();
|
||||||
|
|
||||||
|
if let Ok(contents) = std::fs::read_to_string(&config_path) {
|
||||||
|
eval_source(&mut engine_state, &mut stack, &contents, &config_filename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue