Code coverage report for tasks/utils/log.js

Statements: 45.45% (10 / 22)      Branches: 33.33% (6 / 18)      Functions: 50% (2 / 4)      Lines: 55.56% (10 / 18)      Ignored: none     

All files » tasks/utils/ » log.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 351   1           1           1 1 1     1 5         5       1          
var chalk = require('chalk');
 
function onError(err) {
    if (!err) return;
    console.log(chalk.red(err.message || err));
    process.exit(1);
}
 
function onSuccess(msg) {
    if (!msg) return;
    if (Array.isArray(msg)) msg = msg.join('\n');
    console.log(chalk.green(msg.message || msg));
}
 
function info(msg) {
    Iif (!msg) return;
    console.log(chalk.cyan(msg.message || msg));
}
 
function warn(msg) {
    Iif (msg.toString && typeof msg !== 'string'){
        for (var key in msg){
            console.log(chalk.yellow(msg[key]));
        }
    } else  {
        console.log(chalk.yellow(msg));
    }
}
 
module.exports = {
    info: info,
    warn: warn,
    onError: onError,
    onSuccess: onSuccess
};