From db93c00e72e1b2e276fc3d77853ff722eff5308f Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Wed, 30 Oct 2019 20:11:57 +0000 Subject: [PATCH] added time to go --- changedetection.js | 5 ++++- package-lock.json | 13 +++++++++++++ package.json | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/changedetection.js b/changedetection.js index b2e298f..36fc783 100644 --- a/changedetection.js +++ b/changedetection.js @@ -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(); diff --git a/package-lock.json b/package-lock.json index f98d472..eb56251 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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=" } } } diff --git a/package.json b/package.json index 1ff26e9..bd99fa2 100644 --- a/package.json +++ b/package.json @@ -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",