mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-01-20 14:19:59 -06:00
31 lines
815 B
JavaScript
31 lines
815 B
JavaScript
const chalk = require('chalk')
|
|
|
|
exports.log = (...args) => {
|
|
if (!process.env.VUE_APP_CLI_UI_DEV) return
|
|
const date = new Date()
|
|
const timestamp = `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}.${date.getSeconds().toString().padStart(2, '0')}`
|
|
const first = args.shift()
|
|
console.log(`${chalk.blue('UI')} ${chalk.dim(timestamp)}`, chalk.bold(first), ...args)
|
|
}
|
|
|
|
const simpleTypes = [
|
|
'string',
|
|
'number',
|
|
'boolean'
|
|
]
|
|
|
|
exports.dumpObject = (obj) => {
|
|
if (!process.env.VUE_APP_CLI_UI_DEV) return
|
|
const result = {}
|
|
Object.keys(obj).forEach(key => {
|
|
const value = obj[key]
|
|
const type = typeof value
|
|
if (simpleTypes.includes(type)) {
|
|
result[key] = value
|
|
} else {
|
|
result[key] = type
|
|
}
|
|
})
|
|
return result.toString()
|
|
}
|