Skip to content

Commit a54b428

Browse files
Merge pull request #240 from 07souravkunda/fix_update_notification_issue
Fix update notification issue
2 parents 543d1e7 + b0e2823 commit a54b428

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

bin/commands/runs.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,23 @@ module.exports = function run(args, rawArgs) {
343343
utils.sendUsageReport(bsJsonData, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err), null, rawArgs);
344344
process.exitCode = Constants.ERROR_EXIT_CODE;
345345
}).finally(function(){
346-
updateNotifier({
346+
const notifier = updateNotifier({
347347
pkg,
348348
updateCheckInterval: 1000 * 60 * 60 * 24 * 7,
349-
}).notify({isGlobal: true});
349+
});
350+
351+
// Checks for update on first run.
352+
// Set lastUpdateCheck to 0 to spawn the check update process as notifier sets this to Date.now() for preventing
353+
// the check untill one interval period. It runs once.
354+
if (!notifier.disabled && Date.now() - notifier.config.get('lastUpdateCheck') < 50) {
355+
notifier.config.set('lastUpdateCheck', 0);
356+
notifier.check();
357+
}
358+
359+
// Set the config update as notifier clears this after reading.
360+
if (notifier.update && notifier.update.current !== notifier.update.latest) {
361+
notifier.config.set('update', notifier.update);
362+
notifier.notify({isGlobal: true});
363+
}
350364
});
351365
}

0 commit comments

Comments
 (0)