Skip to content

Commit

Permalink
fix(ui): the logs from creator should be displayed in the UI (#5493)
Browse files Browse the repository at this point in the history
With `logWithSpinner`, the log would be output to the console instead.

Fixes #5240
Fixes #5445
  • Loading branch information
sodatea committed May 18, 2020
1 parent 16d2701 commit 90f1146
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions packages/@vue/cli/lib/Creator.js
Expand Up @@ -32,8 +32,6 @@ const {
log,
warn,
error,
logWithSpinner,
stopSpinner,

hasGit,
hasProjectGit,
Expand Down Expand Up @@ -126,7 +124,7 @@ module.exports = class Creator extends EventEmitter {
const pm = new PackageManager({ context, forcePackageManager: packageManager })

await clearConsole()
logWithSpinner(`✨`, `Creating project in ${chalk.yellow(context)}.`)
log(`✨`, `Creating project in ${chalk.yellow(context)}.`)
this.emit('creation', { event: 'creating' })

// get latest CLI plugin version
Expand Down Expand Up @@ -164,13 +162,12 @@ module.exports = class Creator extends EventEmitter {
// so that vue-cli-service can setup git hooks.
const shouldInitGit = this.shouldInitGit(cliOptions)
if (shouldInitGit) {
logWithSpinner(`πŸ—ƒ`, `Initializing git repository...`)
log(`πŸ—ƒ`, `Initializing git repository...`)
this.emit('creation', { event: 'git-init' })
await run('git init')
}

// install plugins
stopSpinner()
log(`βš™\u{fe0f} Installing CLI plugins. This might take a while...`)
log()
this.emit('creation', { event: 'plugins-install' })
Expand Down Expand Up @@ -205,7 +202,7 @@ module.exports = class Creator extends EventEmitter {
}

// run complete cbs if any (injected by generators)
logWithSpinner('βš“', `Running completion hooks...`)
log('βš“', `Running completion hooks...`)
this.emit('creation', { event: 'completion-hooks' })
for (const cb of afterInvokeCbs) {
await cb()
Expand All @@ -216,9 +213,8 @@ module.exports = class Creator extends EventEmitter {

if (!generator.files['README.md']) {
// generate README.md
stopSpinner()
log()
logWithSpinner('πŸ“„', 'Generating README.md...')
log('πŸ“„', 'Generating README.md...')
await writeFileTree(context, {
'README.md': generateReadme(generator.pkg, packageManager)
})
Expand Down Expand Up @@ -252,7 +248,6 @@ module.exports = class Creator extends EventEmitter {
}

// log instructions
stopSpinner()
log()
log(`πŸŽ‰ Successfully created project ${chalk.yellow(name)}.`)
if (!cliOptions.skipGetStarted) {
Expand Down Expand Up @@ -330,13 +325,11 @@ module.exports = class Creator extends EventEmitter {
} else if (name.endsWith('.json') || /^\./.test(name) || path.isAbsolute(name)) {
preset = await loadLocalPreset(path.resolve(name))
} else if (name.includes('/')) {
logWithSpinner(`Fetching remote preset ${chalk.cyan(name)}...`)
log(`Fetching remote preset ${chalk.cyan(name)}...`)
this.emit('creation', { event: 'fetch-remote-preset' })
try {
preset = await loadRemotePreset(name, clone)
stopSpinner()
} catch (e) {
stopSpinner()
error(`Failed fetching remote preset ${chalk.cyan(name)}:`)
throw e
}
Expand Down

0 comments on commit 90f1146

Please sign in to comment.