Skip to content

Commit a1ccde8

Browse files
author
test
committed
fix: handle failed git commit
close #1306
1 parent 1279b3e commit a1ccde8

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/@vue/cli/lib/Creator.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const {
2626

2727
const {
2828
log,
29+
warn,
2930
error,
3031
hasGit,
3132
hasYarn,
@@ -158,14 +159,19 @@ module.exports = class Creator {
158159
}
159160

160161
// commit initial state
162+
let gitCommitFailed = false
161163
if (shouldInitGit) {
162164
await run('git add -A')
163165
if (isTestOrDebug) {
164166
await run('git', ['config', 'user.name', 'test'])
165167
await run('git', ['config', 'user.email', '[email protected]'])
166168
}
167169
const msg = typeof cliOptions.git === 'string' ? cliOptions.git : 'init'
168-
await run('git', ['commit', '-m', msg])
170+
try {
171+
await run('git', ['commit', '-m', msg])
172+
} catch (e) {
173+
gitCommitFailed = true
174+
}
169175
}
170176

171177
// log instructions
@@ -179,6 +185,13 @@ module.exports = class Creator {
179185
)
180186
log()
181187

188+
if (gitCommitFailed) {
189+
warn(
190+
`Skipped git commit due to missing username and email in git config.\n` +
191+
`You will need to perform the initial commit yourself.\n`
192+
)
193+
}
194+
182195
generator.printExitLogs()
183196
}
184197

0 commit comments

Comments
 (0)