UNPKG

create-strapi-app

Version:

Generate a new Strapi application.

74 lines (70 loc) 1.57 kB
'use strict'; var execa = require('execa'); async function isInGitRepository(rootDir) { try { await execa('git', [ 'rev-parse', '--is-inside-work-tree' ], { stdio: 'ignore', cwd: rootDir }); return true; } catch (_) { return false; } } async function isInMercurialRepository(rootDir) { try { await execa('hg', [ '-cwd', '.', 'root' ], { stdio: 'ignore', cwd: rootDir }); return true; } catch (_) { return false; } } async function tryGitInit(rootDir) { try { await execa('git', [ '--version' ], { stdio: 'ignore' }); if (await isInGitRepository(rootDir) || await isInMercurialRepository(rootDir)) { return false; } await execa('git', [ 'init' ], { stdio: 'ignore', cwd: rootDir }); await execa('git', [ 'add', '.' ], { stdio: 'ignore', cwd: rootDir }); await execa('git', [ 'commit', '-m', 'Initial commit from Strapi' ], { stdio: 'ignore', cwd: rootDir }); return true; } catch (e) { console.error('Error while trying to initialize git:', e); return false; } } exports.tryGitInit = tryGitInit; //# sourceMappingURL=git.js.map