mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-25 09:44:07 +00:00
Unscoped name avoids npm similarity block with create-antd-admin. Bin command antd-admin-cli; release tags antd-admin-cli-v*; workflow publish-antd-admin-cli.yml. Made-with: Cursor
23 lines
686 B
TypeScript
23 lines
686 B
TypeScript
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 antd-admin-cli"],
|
|
{ cwd: root, stdio: "ignore" }
|
|
);
|
|
return true;
|
|
}
|