added time to go

This commit is contained in:
Martin Donnelly 2019-10-30 20:11:57 +00:00
parent 162224bb11
commit db93c00e72
3 changed files with 18 additions and 1 deletions

View File

@ -1,5 +1,6 @@
#!/usr/bin/env node
const CronJob = require('cron').CronJob;
const TimeFormat = require('hh-mm-ss');
// load env variables from file
require('dotenv').config();
@ -31,8 +32,10 @@ async function run() {
setInterval(async () => {
const now = new Date();
const nowTS = now.getTime();
const m = parseInt(process.env.CD_EVERY, 10) - (nowTS - startTimeStamp);
const remains = TimeFormat.fromMs(m, 'hh:mm:ss');
console.log('check');
console.log(`${remains} to go...`);
if (nowTS - startTimeStamp > process.env.CD_EVERY) {
await cdScraper.run();

13
package-lock.json generated
View File

@ -1252,6 +1252,14 @@
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="
},
"hh-mm-ss": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/hh-mm-ss/-/hh-mm-ss-1.2.0.tgz",
"integrity": "sha512-f4I9Hz1dLpX/3mrEs7yq30+FiuO3tt5NWAqAGeBTaoeoBfB8vhcQ3BphuDc5DjZb/K809agqrAaFlP0jhEU/8w==",
"requires": {
"zero-fill": "^2.2.3"
}
},
"html-differ": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/html-differ/-/html-differ-1.4.0.tgz",
@ -2847,6 +2855,11 @@
"requires": {
"fd-slicer": "~1.0.1"
}
},
"zero-fill": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/zero-fill/-/zero-fill-2.2.3.tgz",
"integrity": "sha1-o97wa6XjmuZEhQu0yirUEStIVek="
}
}
}

View File

@ -16,6 +16,7 @@
"dotenv": "^8.2.0",
"fecha": "^3.0.3",
"fs-extra": "latest",
"hh-mm-ss": "^1.2.0",
"html-differ": "^1.4.0",
"jsonfile": "^5.0.0",
"lodash": "^4.17.15",