UNPKG

922 BJavaScriptView Raw
1// Adapted from Vue CLI v2 "init" command
2
3const chalk = require('chalk')
4const format = require('util').format
5
6/**
7 * Prefix.
8 */
9
10const prefix = ' Quasar CLI'
11const sep = chalk.gray('·')
12
13/**
14 * Log a `message` to the console.
15 *
16 * @param {String} message
17 */
18
19exports.log = function (...args) {
20 const msg = format.apply(format, args)
21 console.log(chalk.white(prefix), sep, msg)
22}
23
24/**
25 * Log an error `message` to the console and exit.
26 *
27 * @param {String} message
28 */
29
30module.exports.fatal = function (...args) {
31 if (args[0] instanceof Error) args[0] = args[0].message.trim()
32 const msg = format.apply(format, args)
33 console.error(chalk.red(prefix), sep, msg)
34 process.exit(1)
35}
36
37/**
38 * Log a success `message` to the console and exit.
39 *
40 * @param {String} message
41 */
42
43module.exports.success = function (...args) {
44 const msg = format.apply(format, args)
45 console.log(chalk.white(prefix), sep, msg)
46}