mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-20 00:52:41 +03:00
24 lines
505 B
TypeScript
24 lines
505 B
TypeScript
|
import chalk from 'chalk'
|
||
|
import ms from 'ms'
|
||
|
|
||
|
let prevTime: number
|
||
|
|
||
|
export default (banner: string, color: string = 'green') => {
|
||
|
return (msg?: string) => {
|
||
|
const curr = +new Date()
|
||
|
const diff = curr - (prevTime || curr)
|
||
|
|
||
|
prevTime = curr
|
||
|
|
||
|
if (msg) {
|
||
|
console.log(
|
||
|
// TODO: proper typings for color and banner
|
||
|
// @ts-ignore
|
||
|
` ${chalk[String(color)](String(banner))} ${msg} ${chalk.green(`+${ms(diff)}`)}`
|
||
|
)
|
||
|
} else {
|
||
|
console.log()
|
||
|
}
|
||
|
}
|
||
|
}
|