Skip to content

Commit c2aac9e

Browse files
committed
refactor: merge skipGit and initialCommit options
1 parent 8e72943 commit c2aac9e

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

packages/@vue/cli-plugin-eslint/__tests__/eslintPlugin.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test('should work', async () => {
2121
lintOn: 'commit'
2222
}
2323
}
24-
})
24+
}, null, true /* initGit */)
2525
const { read, write, run } = project
2626
// should've applied airbnb autofix
2727
const main = await read('src/main.js')

packages/@vue/cli-test-utils/createTestProject.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const writeFile = promisify(fs.writeFile)
77
const rmFile = promisify(fs.unlink)
88
const mkdirp = promisify(require('mkdirp'))
99

10-
module.exports = function createTestProject (name, preset, cwd) {
10+
module.exports = function createTestProject (name, preset, cwd, initGit) {
1111
cwd = cwd || path.resolve(__dirname, '../../test')
1212

1313
const projectRoot = path.resolve(cwd, name)
@@ -46,7 +46,9 @@ module.exports = function createTestProject (name, preset, cwd) {
4646
name,
4747
'--force',
4848
'--inlinePreset',
49-
JSON.stringify(preset)
49+
JSON.stringify(preset),
50+
'--git',
51+
initGit ? 'init' : 'false'
5052
]
5153

5254
const options = {

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ program
4141
.option('-i, --inlinePreset <json>', 'Skip prompts and use inline JSON string as preset')
4242
.option('-m, --packageManager <command>', 'Use specified npm client when installing dependencies')
4343
.option('-r, --registry <url>', 'Use specified npm registry when installing dependencies (only for npm)')
44-
.option('-s, --skipGit', 'Do not setup git repository when creating project')
45-
.option('-g, --git <message>', 'Specify initial commit message (when git is available)')
44+
.option('-g, --git [message]', 'Force / skip git intialization, optionally specify initial commit message')
4645
.option('-f, --force', 'Overwrite target directory if it exists')
4746
.option('-c, --clone', 'Use git clone when fetching remote preset')
4847
.action((name, cmd) => {

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ module.exports = class Creator {
163163
await run('git', ['config', 'user.name', 'test'])
164164
await run('git', ['config', 'user.email', '[email protected]'])
165165
}
166-
await run('git', ['commit', '-m', cliOptions.initialCommit || 'init'])
166+
const msg = typeof cliOptions.git === 'string' ? cliOptions.git : 'init'
167+
await run('git', ['commit', '-m', msg])
167168
}
168169

169170
// log instructions
@@ -388,8 +389,8 @@ module.exports = class Creator {
388389
if (!hasGit()) {
389390
return false
390391
}
391-
if (cliOptions.skipGit) {
392-
return false
392+
if (cliOptions.git) {
393+
return cliOptions.git !== 'false'
393394
}
394395
// check if we are in a git repo already
395396
try {

0 commit comments

Comments
 (0)