-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathlogger.js
More file actions
43 lines (35 loc) Β· 916 Bytes
/
logger.js
File metadata and controls
43 lines (35 loc) Β· 916 Bytes
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
35
36
37
38
39
40
41
42
43
const clocks = ['π', 'π', 'π', 'π', 'π', 'π', 'π', 'π', 'π', 'π', 'π', 'π']
function logger(bundle, mode) {
let cindex = 0
let timer = null
let stoped = false
function dots() {
return Array((cindex % 3) + 1).fill('.').join('')
}
function reset() {
if (process.stdout.clearLine) {
process.stdout.clearLine()
process.stdout.cursorTo(0)
}
}
function start() {
reset()
if (cindex >= clocks.length) {
cindex = 0
}
let symbol = clocks[cindex]
process.stdout.write(` ${symbol} Building your ${bundle} in ${mode} mode ${dots()}`)
cindex++;
timer = setTimeout(start, 200)
}
start()
function stop() {
if (stoped) return
clearTimeout(timer)
reset()
process.stdout.write(` β
Starting your ${bundle} in ${mode} mode\n`)
stoped = true
}
return { stop }
}
module.exports = logger