Skip to content

Commit

Permalink
fix: handle failed git commit
Browse files Browse the repository at this point in the history
close #1306
  • Loading branch information
test committed May 17, 2018
1 parent 1279b3e commit a1ccde8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/@vue/cli/lib/Creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const {

const {
log,
warn,
error,
hasGit,
hasYarn,
Expand Down Expand Up @@ -158,14 +159,19 @@ module.exports = class Creator {
}

// commit initial state
let gitCommitFailed = false
if (shouldInitGit) {
await run('git add -A')
if (isTestOrDebug) {
await run('git', ['config', 'user.name', 'test'])
await run('git', ['config', 'user.email', 'test@test.com'])
}
const msg = typeof cliOptions.git === 'string' ? cliOptions.git : 'init'
await run('git', ['commit', '-m', msg])
try {
await run('git', ['commit', '-m', msg])
} catch (e) {
gitCommitFailed = true
}
}

// log instructions
Expand All @@ -179,6 +185,13 @@ module.exports = class Creator {
)
log()

if (gitCommitFailed) {
warn(
`Skipped git commit due to missing username and email in git config.\n` +
`You will need to perform the initial commit yourself.\n`
)
}

generator.printExitLogs()
}

Expand Down

0 comments on commit a1ccde8

Please sign in to comment.