mirror of
https://github.com/zuiidea/antd-admin.git
synced 2026-10-19 16:14:37 +00:00
feat(create): optional git init and initial commit
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
export function tryGitInit(root: string, enabled: boolean): boolean {
|
||||
if (!enabled) {
|
||||
const gitDir = path.join(root, ".git");
|
||||
if (fs.existsSync(gitDir)) {
|
||||
fs.rmSync(gitDir, { recursive: true, force: true });
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const init = spawnSync("git", ["init"], { cwd: root, stdio: "ignore" });
|
||||
if (init.status !== 0) return false;
|
||||
spawnSync("git", ["add", "-A"], { cwd: root, stdio: "ignore" });
|
||||
spawnSync(
|
||||
"git",
|
||||
["commit", "-m", "chore: initial commit from create-antd-admin"],
|
||||
{ cwd: root, stdio: "ignore" }
|
||||
);
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user