mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-01-18 13:20:17 -06:00
fix(create): fix force git init
This commit is contained in:
@@ -49,13 +49,18 @@ program
|
||||
.option('-i, --inlinePreset <json>', 'Skip prompts and use inline JSON string as preset')
|
||||
.option('-m, --packageManager <command>', 'Use specified npm client when installing dependencies')
|
||||
.option('-r, --registry <url>', 'Use specified npm registry when installing dependencies (only for npm)')
|
||||
.option('-g, --git [message]', 'Force git initialization with optional initial commit message')
|
||||
.option('-g, --git [message]', 'Force git initialization with initial commit message')
|
||||
.option('-n, --no-git', 'Skip git initialization')
|
||||
.option('-f, --force', 'Overwrite target directory if it exists')
|
||||
.option('-c, --clone', 'Use git clone when fetching remote preset')
|
||||
.option('-x, --proxy', 'Use specified proxy when creating project')
|
||||
.action((name, cmd) => {
|
||||
require('../lib/create')(name, cleanArgs(cmd))
|
||||
const options = cleanArgs(cmd)
|
||||
// --no-git makes commander to default git to true
|
||||
if (process.argv.includes('-g') || process.argv.includes('--git')) {
|
||||
options.forceGit = true
|
||||
}
|
||||
require('../lib/create')(name, options)
|
||||
})
|
||||
|
||||
program
|
||||
|
||||
@@ -440,10 +440,15 @@ module.exports = class Creator extends EventEmitter {
|
||||
if (!hasGit()) {
|
||||
return false
|
||||
}
|
||||
if (typeof cliOptions.git !== 'undefined') {
|
||||
return cliOptions.git !== 'false' && cliOptions.git !== false
|
||||
// --git
|
||||
if (cliOptions.forceGit) {
|
||||
return true
|
||||
}
|
||||
|
||||
// --no-git
|
||||
if (cliOptions.git === false || cliOptions.git === 'false') {
|
||||
return false
|
||||
}
|
||||
// default: true unless already in a git repo
|
||||
return !hasProjectGit(this.context)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user