UNPKG

628 Btext/coffeescriptView Raw
1inquirer = require 'inquirer'
2chalk = require 'chalk'
3
4animation = ['/', '–', '\\', '|']
5
6spinner = (speed=1) ->
7 ui = new inquirer.ui.BottomBar
8 i = 0
9 ui.updateBottomBar animation[i]
10 interval = setInterval ->
11 i = (i + 1) %% animation.length
12 ui.updateBottomBar animation[i]
13 , 100 // speed
14
15 ->
16 clearInterval interval
17 ui.updateBottomBar ''
18
19log = {}
20levels =
21 info: 'cyan'
22 success: 'green'
23 warn: 'yellow'
24 error: 'red'
25for level, color of levels
26 do (level, color) ->
27 log[level] = (args...) -> console.log '\n', (chalk[color] arg for arg in args)..., '\n'
28
29module.exports = {log, spinner}
\No newline at end of file