feat: init new git repo for new projects (#558)

This commit is contained in:
Jacob Marshall
2025-04-08 17:03:42 +01:00
committed by GitHub
parent f449c4537e
commit b17521063a
+15
View File
@@ -6,6 +6,8 @@ use std::env;
use std::fs::{self, File, OpenOptions, create_dir};
use std::io::{self, prelude::*};
use std::path::{Path, PathBuf};
use std::process::Command;
use tracing::trace;
#[derive(Deserialize, Debug)]
enum GithubFileType {
@@ -156,6 +158,9 @@ pub fn create_new_project(
update_package_json_version(&folder_path).expect("Failed to update package.json version");
update_cargo_toml_version(&folder_path).expect("Failed to update Cargo.toml version");
init_new_git_repo(&folder_path);
outro(folder);
}
@@ -265,6 +270,16 @@ fn update_cargo_toml_version(folder_path: &Path) -> io::Result<()> {
Ok(())
}
fn init_new_git_repo(folder_path: &Path) {
if let Ok(output) = Command::new("git").arg("init").arg(folder_path).output() {
if !output.status.success() {
trace!("Failed to initialise a new git repo")
}
} else {
trace!("Failed to initialise a new git repo")
}
}
fn outro(folder_name: String) {
println!("Success! 🎉");