UNPKG

894 BJavaScriptView Raw
1var chalk = require('chalk')
2var format = require('util').format
3
4/**
5 * Prefix.
6 */
7
8var prefix = ' cbd-cli'
9var sep = chalk.gray('·')
10
11/**
12 * Log a `message` to the console.
13 *
14 * @param {String} message
15 */
16
17exports.log = function () {
18 var msg = format.apply(format, arguments)
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 (message) {
29 if (message instanceof Error) message = message.message.trim()
30 var msg = format.apply(format, arguments)
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 () {
42 var msg = format.apply(format, arguments)
43 console.log(chalk.white(prefix), sep, msg)
44}