Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat exit message #935

Merged
merged 3 commits into from
Mar 4, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(logger): add tag argument
  • Loading branch information
Guillaume Chau committed Mar 3, 2018
commit e20c49cbdf37487ab66c57030d0f510b8346d365
20 changes: 11 additions & 9 deletions packages/@vue/cli-shared-utils/lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@ const format = (label, msg) => {
}).join('\n')
}

exports.log = msg => console.log(msg || '')
const chalkTag = msg => chalk.bgBlackBright.white.dim(` ${msg} `)

exports.info = msg => {
console.log(format(chalk.bgBlue.black(' INFO '), msg))
exports.log = (msg = '', tag = null) => tag ? console.log(format(chalkTag(tag), msg)) : console.log(msg)

exports.info = (msg, tag = null) => {
console.log(format(chalk.bgBlue.black(' INFO ') + (tag ? chalkTag(tag) : ''), msg))
}

exports.done = msg => {
console.log(format(chalk.bgGreen.black(' DONE '), msg))
exports.done = (msg, tag = null) => {
console.log(format(chalk.bgGreen.black(' DONE ') + (tag ? chalkTag(tag) : ''), msg))
}

exports.warn = msg => {
console.warn(format(chalk.bgYellow.black(' WARN '), chalk.yellow(msg)))
exports.warn = (msg, tag = null) => {
console.warn(format(chalk.bgYellow.black(' WARN ') + (tag ? chalkTag(tag) : ''), chalk.yellow(msg)))
}

exports.error = msg => {
console.error(format(chalk.bgRed(' ERROR '), chalk.red(msg)))
exports.error = (msg, tag = null) => {
console.error(format(chalk.bgRed(' ERROR ') + (tag ? chalkTag(tag) : ''), chalk.red(msg)))
if (msg instanceof Error) {
console.error(msg.stack)
}
Expand Down