Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

fix: check if we are already inside git repo before initGit #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/GeneratorContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down