diff --git a/bin/commands/runs.js b/bin/commands/runs.js index 57dfa7b1..b6706072 100644 --- a/bin/commands/runs.js +++ b/bin/commands/runs.js @@ -324,9 +324,23 @@ module.exports = function run(args, rawArgs) { utils.sendUsageReport(bsJsonData, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err), null, rawArgs); process.exitCode = Constants.ERROR_EXIT_CODE; }).finally(function(){ - updateNotifier({ + const notifier = updateNotifier({ pkg, updateCheckInterval: 1000 * 60 * 60 * 24 * 7, - }).notify({isGlobal: true}); + }); + + // Checks for update on first run. + // Set lastUpdateCheck to 0 to spawn the check update process as notifier sets this to Date.now() for preventing + // the check untill one interval period. It runs once. + if (!notifier.disabled && Date.now() - notifier.config.get('lastUpdateCheck') < 50) { + notifier.config.set('lastUpdateCheck', 0); + notifier.check(); + } + + // Set the config update as notifier clears this after reading. + if (notifier.update && notifier.update.current !== notifier.update.latest) { + notifier.config.set('update', notifier.update); + notifier.notify({isGlobal: true}); + } }); }