Skip to content

Commit

Permalink
feat: git init to main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
sinedied committed Oct 5, 2021
1 parent 5f86477 commit 867d905
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,20 @@ export async function getRepository(string?: string, searchPackageUp = true): Pr
);
}

export async function isGitRepository() {
return (await hasGitInstalled()) && fs.pathExists('.git');
}

export async function initGitRepository() {
try {
await execa('git', ['init']);
debug('Git repository initialized');
// TODO: set git main branch if not already inited

const currentBranch = await getCurrentBranchFromGit();
if (currentBranch !== 'main') {
await execa('git', ['branch', '-M', 'main']);
debug('Git: renamed branch to "main"');
}
} catch (error) {
debug(`Git error: ${String(error as Error)}`);
}
Expand Down

0 comments on commit 867d905

Please sign in to comment.