@electron-forge/core
Version:
A complete tool for building modern Electron applications
27 lines (23 loc) • 688 B
text/typescript
import { exec } from 'child_process';
import debug from 'debug';
const d = debug('electron-forge:init:git');
export const initGit = async (dir: string): Promise<void> => {
await new Promise<void>((resolve, reject) => {
exec(
'git rev-parse --show-toplevel',
{
cwd: dir,
},
(err) => {
if (err) {
// not run within a Git repository
d('executing "git init" in directory:', dir);
exec('git init', { cwd: dir }, (initErr) => (initErr ? reject(initErr) : resolve()));
} else {
d('.git directory already exists, skipping git initialization');
resolve();
}
}
);
});
};