@@ -5,7 +5,7 @@ const Creator = require('@vue/cli/lib/Creator')
55const { getPromptModules } = require ( '@vue/cli/lib/util/createTools' )
66const { getFeatures } = require ( '@vue/cli/lib/util/features' )
77const { defaults } = require ( '@vue/cli/lib/options' )
8- const { toShortPluginId, clearModule } = require ( '@vue/cli-shared-utils' )
8+ const { toShortPluginId, execa } = require ( '@vue/cli-shared-utils' )
99const { progress : installProgress } = require ( '@vue/cli/lib/util/installDeps' )
1010const parseGitConfig = require ( 'parse-git-config' )
1111// Connectors
@@ -15,6 +15,7 @@ const prompts = require('./prompts')
1515const folders = require ( './folders' )
1616const plugins = require ( './plugins' )
1717const locales = require ( './locales' )
18+ const logs = require ( './logs' )
1819// Context
1920const getContext = require ( '../context' )
2021// Utils
@@ -258,53 +259,23 @@ async function create (input, context) {
258259
259260 const targetDir = path . join ( cwd . get ( ) , input . folder )
260261
261- // Delete existing folder
262- if ( fs . existsSync ( targetDir ) ) {
263- if ( input . force ) {
264- setProgress ( {
265- info : 'Cleaning folder...'
266- } )
267- await folders . delete ( targetDir )
268- setProgress ( {
269- info : null
270- } )
271- } else {
272- throw new Error ( `Folder ${ targetDir } already exists` )
273- }
274- }
275-
276262 cwd . set ( targetDir , context )
277263 creator . context = targetDir
278264
279- process . env . VUE_CLI_CONTEXT = targetDir
280- clearModule ( '@vue/cli-service/webpack.config.js' , targetDir )
281-
282265 const inCurrent = input . folder === '.'
283- const name = inCurrent ? path . relative ( '../' , process . cwd ( ) ) : input . folder
284- creator . name = name . toLowerCase ( )
266+ const name = creator . name = ( inCurrent ? path . relative ( '../' , process . cwd ( ) ) : input . folder ) . toLowerCase ( )
285267
286268 // Answers
287269 const answers = prompts . getAnswers ( )
288270 await prompts . reset ( )
289- let index
290271
291272 // Config files
273+ let index
292274 if ( ( index = answers . features . indexOf ( 'use-config-files' ) ) !== - 1 ) {
293275 answers . features . splice ( index , 1 )
294276 answers . useConfigFiles = 'files'
295277 }
296278
297- const createOptions = {
298- packageManager : input . packageManager ,
299- bare : input . bare
300- }
301- // Git
302- if ( input . enableGit && input . gitCommitMessage ) {
303- createOptions . git = input . gitCommitMessage
304- } else {
305- createOptions . git = input . enableGit
306- }
307-
308279 // Preset
309280 answers . preset = input . preset
310281 if ( input . save ) {
@@ -330,7 +301,49 @@ async function create (input, context) {
330301 } )
331302
332303 // Create
333- await creator . create ( createOptions , preset )
304+ const args = [
305+ '--skipGetStarted'
306+ ]
307+ if ( input . packageManager ) args . push ( '--packageManager' , input . packageManager )
308+ if ( input . bar ) args . push ( '--bare' )
309+ if ( input . force ) args . push ( '--force' )
310+ // Git
311+ if ( input . enableGit && input . gitCommitMessage ) {
312+ args . push ( '--git' , input . gitCommitMessage )
313+ } else if ( ! input . enableGit ) {
314+ args . push ( '--no-git' )
315+ }
316+ // Preset
317+ args . push ( '--inlinePreset' , JSON . stringify ( preset ) )
318+
319+ log ( 'create' , name , args )
320+
321+ const child = execa ( 'vue' , [
322+ 'create' ,
323+ name ,
324+ ...args
325+ ] , {
326+ cwd : cwd . get ( ) ,
327+ stdio : [ 'inherit' , 'pipe' , 'inherit' ]
328+ } )
329+
330+ const onData = buffer => {
331+ const text = buffer . toString ( ) . trim ( )
332+ if ( text ) {
333+ setProgress ( {
334+ info : text
335+ } )
336+ logs . add ( {
337+ type : 'info' ,
338+ message : text
339+ } , context )
340+ }
341+ }
342+
343+ child . stdout . on ( 'data' , onData )
344+
345+ await child
346+
334347 removeCreator ( )
335348
336349 notify ( {
0 commit comments