2
0
mirror of https://github.com/frappe/books.git synced 2024-11-14 01:14:03 +00:00
books/webpack/logger.js

20 lines
438 B
JavaScript
Raw Normal View History

const ms = require('ms');
const chalk = require('chalk');
let prevTime;
module.exports = function (banner, color = 'green') {
return function (message) {
const currentTime = +new Date();
const diff = currentTime - (prevTime || currentTime);
prevTime = currentTime;
if (message) {
console.log(` ${chalk[color](banner)} ${message} ${chalk.green(`+${ms(diff)}`)}`)
}
else {
console.log()
}
}
}