mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-29 16:30:33 -05:00
refactor: merge skipGit and initialCommit options
This commit is contained in:
@@ -21,7 +21,7 @@ test('should work', async () => {
|
||||
lintOn: 'commit'
|
||||
}
|
||||
}
|
||||
})
|
||||
}, null, true /* initGit */)
|
||||
const { read, write, run } = project
|
||||
// should've applied airbnb autofix
|
||||
const main = await read('src/main.js')
|
||||
|
||||
@@ -7,7 +7,7 @@ const writeFile = promisify(fs.writeFile)
|
||||
const rmFile = promisify(fs.unlink)
|
||||
const mkdirp = promisify(require('mkdirp'))
|
||||
|
||||
module.exports = function createTestProject (name, preset, cwd) {
|
||||
module.exports = function createTestProject (name, preset, cwd, initGit) {
|
||||
cwd = cwd || path.resolve(__dirname, '../../test')
|
||||
|
||||
const projectRoot = path.resolve(cwd, name)
|
||||
@@ -46,7 +46,9 @@ module.exports = function createTestProject (name, preset, cwd) {
|
||||
name,
|
||||
'--force',
|
||||
'--inlinePreset',
|
||||
JSON.stringify(preset)
|
||||
JSON.stringify(preset),
|
||||
'--git',
|
||||
initGit ? 'init' : 'false'
|
||||
]
|
||||
|
||||
const options = {
|
||||
|
||||
@@ -41,8 +41,7 @@ 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('-s, --skipGit', 'Do not setup git repository when creating project')
|
||||
.option('-g, --git <message>', 'Specify initial commit message (when git is available)')
|
||||
.option('-g, --git [message]', 'Force / skip git intialization, optionally specify initial commit message')
|
||||
.option('-f, --force', 'Overwrite target directory if it exists')
|
||||
.option('-c, --clone', 'Use git clone when fetching remote preset')
|
||||
.action((name, cmd) => {
|
||||
|
||||
@@ -163,7 +163,8 @@ module.exports = class Creator {
|
||||
await run('git', ['config', 'user.name', 'test'])
|
||||
await run('git', ['config', 'user.email', 'test@test.com'])
|
||||
}
|
||||
await run('git', ['commit', '-m', cliOptions.initialCommit || 'init'])
|
||||
const msg = typeof cliOptions.git === 'string' ? cliOptions.git : 'init'
|
||||
await run('git', ['commit', '-m', msg])
|
||||
}
|
||||
|
||||
// log instructions
|
||||
@@ -388,8 +389,8 @@ module.exports = class Creator {
|
||||
if (!hasGit()) {
|
||||
return false
|
||||
}
|
||||
if (cliOptions.skipGit) {
|
||||
return false
|
||||
if (cliOptions.git) {
|
||||
return cliOptions.git !== 'false'
|
||||
}
|
||||
// check if we are in a git repo already
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user