All files / init init-git.js

90.91% Statements 10/11
75% Branches 3/4
100% Functions 4/4
100% Lines 10/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27              1x     6x 6x 6x 1x 1x   5x 5x     5x 5x          
import { exec } from 'child_process';
import debug from 'debug';
import fs from 'fs-promise';
import path from 'path';
 
import asyncOra from '../util/ora-handler';
 
const d = debug('electron-forge:init:git');
 
export default async (dir) => {
  await asyncOra('Initializing Git Repository', async () => {
    await new Promise(async (resolve, reject) => {
      if (await fs.exists(path.resolve(dir, '.git'))) {
        d('.git directory already exists, skipping git initialization');
        return resolve();
      }
      d('executing "git init" in directory:', dir);
      exec('git init', {
        cwd: dir,
      }, (err) => {
        Iif (err) return reject(err);
        resolve();
      });
    });
  });
};