Newer
Older
/* eslint-disable import/no-extraneous-dependencies */
import { execSync } from "child_process";
import fs from "fs";
import path from "path";
function isInGitRepository(): boolean {
try {
execSync("git rev-parse --is-inside-work-tree", { stdio: "ignore" });
return true;
}
function isInMercurialRepository(): boolean {
try {
execSync("hg --cwd . root", { stdio: "ignore" });
return true;
}
function isDefaultBranchSet(): boolean {
try {
execSync("git config init.defaultBranch", { stdio: "ignore" });
return true;
}
export function tryGitInit(root: string): boolean {
if (isInGitRepository() || isInMercurialRepository()) {
execSync("git init", { stdio: "ignore" });
didInit = true;
execSync('git commit -m "Initial commit from Create Llama"', {
fs.rmSync(path.join(root, ".git"), { recursive: true, force: true });