diff options
Diffstat (limited to 'cli/tools/init/mod.rs')
-rw-r--r-- | cli/tools/init/mod.rs | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/cli/tools/init/mod.rs b/cli/tools/init/mod.rs index f0da86006..9e46359c0 100644 --- a/cli/tools/init/mod.rs +++ b/cli/tools/init/mod.rs @@ -14,13 +14,22 @@ fn create_file( filename: &str, content: &str, ) -> Result<(), AnyError> { - let mut file = std::fs::OpenOptions::new() - .write(true) - .create_new(true) - .open(dir.join(filename)) - .with_context(|| format!("Failed to create {filename} file"))?; - file.write_all(content.as_bytes())?; - Ok(()) + let path = dir.join(filename); + if path.exists() { + info!( + "ℹ️ {}", + colors::gray(format!("Skipped creating {filename} as it already exists")) + ); + Ok(()) + } else { + let mut file = std::fs::OpenOptions::new() + .write(true) + .create_new(true) + .open(path) + .with_context(|| format!("Failed to create {filename} file"))?; + file.write_all(content.as_bytes())?; + Ok(()) + } } pub async fn init_project(init_flags: InitFlags) -> Result<(), AnyError> { |