mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
20 lines
438 B
JavaScript
20 lines
438 B
JavaScript
|
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()
|
||
|
}
|
||
|
}
|
||
|
}
|