From 63d57b046dd9eeba884dac1c6c9629b567b03b0e Mon Sep 17 00:00:00 2001 From: Seyyed Morteza Moosavi Date: Sun, 15 Sep 2019 11:35:14 +0430 Subject: [PATCH] fix: check if we are already inside git repo before initGit --- lib/GeneratorContext.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/GeneratorContext.js b/lib/GeneratorContext.js index 7a056a1..5add9a7 100644 --- a/lib/GeneratorContext.js +++ b/lib/GeneratorContext.js @@ -44,7 +44,21 @@ module.exports = class GeneratorContext { return require('./installPackages').getNpmClient() } + isInsideGitRepo() { + const ps = spawn.sync('git', ['rev-parse', '--git-dir'], { + stdio: 'ignore', + cwd: this.outDir + }) + return ps.status === 0 + } + gitInit() { + if (this.isInsideGitRepo()) { + logger.info( + 'Initialization of Git repo ignored because we are inside a Git repo right now' + ) + return + } const ps = spawn.sync('git', ['init'], { stdio: 'ignore', cwd: this.outDir