-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.js
38 lines (30 loc) · 869 Bytes
/
index.js
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
const cliProgress = require('cli-progress')
const axios = require('axios')
let obj = {
current: 0,
next: 0
}
let total = 0
// container
const multibar = new cliProgress.MultiBar({
clearOnComplete: false,
hideCursor: true,
format: '{version} | {bar} {percentage}% | {value}/{total}'
}, cliProgress.Presets.shades_grey)
// bars
const b1 = multibar.create(0, 0)
const b2 = multibar.create(0, 0)
setInterval(async () => {
var ret = ''
try {
ret = await axios.get('http://canary.jeromedecoster.net/')
ret = ret.data.trim()
} catch(err) {}
if (ret.includes('1-0-0')) obj.current++
else if (ret.includes('1-1-0')) obj.next++
total = obj.current + obj.next
b1.update(obj.current, {version: '1-0-0'})
b2.update(obj.next, {version: '1-1-0'})
b1.setTotal(total)
b2.setTotal(total)
}, 500)