forked from WalletScrutiny/WalletScrutinyCom
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrefreshApps.js
More file actions
36 lines (34 loc) · 1.24 KB
/
refreshApps.js
File metadata and controls
36 lines (34 loc) · 1.24 KB
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
const appStore = require('./scripts/helperAppStore.js')
const playStore = require('./scripts/helperPlayStore.js')
const fs = require('fs')
const dateFormat = require('dateformat')
const readline = require('readline')
async function refresh (skip) {
fs.appendFileSync('_data/defunct.yaml', `${dateFormat(new Date(), 'yyyy-mm-dd')}:\n`)
if (!skip) appStore.refreshAll()
playStore.refreshAll(skip)
const updateMillis = 500
var msg = ''
var msgAgeMs = 0
const i = setInterval(() => {
const newMsg = `remaining: ${playStore.stats.remaining + appStore.stats.remaining}, 🤖: defunct ${playStore.stats.defunct}, updated ${playStore.stats.updated}, 🍎: defunct ${appStore.stats.defunct}, updated ${appStore.stats.updated}`
readline.clearLine(process.stdout)
readline.cursorTo(process.stdout, 0)
process.stdout.write(newMsg)
readline.cursorTo(process.stdout, 0) // other console.out stuff should write over this.
if (msg === newMsg) {
msgAgeMs += updateMillis
} else {
msg = newMsg
msgAgeMs = 0
}
if (playStore.stats.remaining + appStore.stats.remaining === 0 || msgAgeMs > 30000) {
console.log(`
Finished.`)
clearInterval(i)
}
}, updateMillis)
}
module.exports = {
refresh
}