UNPKG

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