@@ -10,13 +10,12 @@ pub fn config_file() -> PathBuf {
1010 env::var("BAT_CONFIG_PATH")
1111 .ok()
1212 .map(PathBuf::from)
13− .filter(|config_path| config_path.is_file())
1413 .unwrap_or_else(|| PROJECT_DIRS.config_dir().join("config"))
1514}
1615
1716pub fn generate_config_file() -> bat::error::Result<()> {
1817 let config_file = config_file();
19− if config_file.exists() {
18+ if config_file.is_file() {
2019 println!(
2120 "A config file already exists at: {}",
2221 config_file.to_string_lossy()
@@ -71,7 +70,14 @@ pub fn generate_config_file() -> bat::error::Result<()> {
7170#--map-syntax ".ignore:Git Ignore"
7271"#;
7372
74− fs::write(&config_file, default_config)?;
73+ fs::write(&config_file, default_config).map_err(|e| {
74+ format!(
75+ "Failed to create config file at '{}': {}",
76+ config_file.to_string_lossy(),
77+ e
78+ )
79+ })?;
80+
7581 println!(
7682 "Success! Config file written to {}",
7783 config_file.to_string_lossy()