Skip to content

Commit 7e6c37c

Browse files
haoqunjiangyyx990803
authored andcommitted
fix(create): fix shouldInitGit check (vuejs#1901)
Also improve skip git flag description (`--git false` -> `--no-git`)
1 parent 3936dfc commit 7e6c37c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/@vue/cli/bin/vue.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ program
4949
.option('-i, --inlinePreset <json>', 'Skip prompts and use inline JSON string as preset')
5050
.option('-m, --packageManager <command>', 'Use specified npm client when installing dependencies')
5151
.option('-r, --registry <url>', 'Use specified npm registry when installing dependencies (only for npm)')
52-
.option('-g, --git [message]', 'Force / skip git initialization, optionally specify initial commit message')
52+
.option('-g, --git [message]', 'Force git initialization with optional initial commit message')
53+
.option('-n, --no-git', 'Skip git initialization')
5354
.option('-f, --force', 'Overwrite target directory if it exists')
5455
.option('-c, --clone', 'Use git clone when fetching remote preset')
5556
.option('-x, --proxy', 'Use specified proxy when creating project')
@@ -187,7 +188,7 @@ function cleanArgs (cmd) {
187188
const key = o.long.replace(/^--/, '')
188189
// if an option is not present and Command has a method with the same name
189190
// it should not be copied
190-
if (typeof cmd[key] !== 'function') {
191+
if (typeof cmd[key] !== 'function' && typeof cmd[key] !== 'undefined') {
191192
args[key] = cmd[key]
192193
}
193194
})

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ module.exports = class Creator extends EventEmitter {
440440
if (!hasGit()) {
441441
return false
442442
}
443-
if (cliOptions.git) {
443+
if (typeof cliOptions.git !== 'undefined') {
444444
return cliOptions.git !== 'false' && cliOptions.git !== false
445445
}
446446

0 commit comments

Comments
 (0)