Skip to content

Commit

Permalink
Merge pull request #841 from browserstack/bump_update_notifier
Browse files Browse the repository at this point in the history
Bump the version of update-notifier package
  • Loading branch information
pranavj1001 authored Jul 5, 2024
2 parents 7371302 + 3cd2cf2 commit 010d90b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
37 changes: 20 additions & 17 deletions bin/commands/runs.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const archiver = require("../helpers/archiver"),
{initTimeComponents, instrumentEventTime, markBlockStart, markBlockEnd, getTimeComponents} = require('../helpers/timeComponents'),
downloadBuildArtifacts = require('../helpers/buildArtifacts').downloadBuildArtifacts,
downloadBuildStacktrace = require('../helpers/downloadBuildStacktrace').downloadBuildStacktrace,
updateNotifier = require('update-notifier'),
pkg = require('../../package.json'),
packageDiff = require('../helpers/package-diff');
const { getStackTraceUrl } = require('../helpers/sync/syncSpecsLogs');
Expand Down Expand Up @@ -531,23 +530,27 @@ 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(){
const notifier = updateNotifier({
pkg,
updateCheckInterval: 1000 * 60 * 60 * 24 * 7,
});
import('update-notifier').then(({ default: updateNotifier } ) => {
const notifier = updateNotifier({
pkg,
updateCheckInterval: 1000 * 60 * 60 * 24 * 7,
});

// 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();
}
// 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});
}
// 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});
}
}).catch((error) => {
logger.debug('Got error loading update-notifier: ', error);
});
});
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"request": "2.88.2",
"requestretry": "7.1.0",
"table": "5.4.6",
"update-notifier": "5.1.0",
"update-notifier": "7.0.0",
"uuid": "8.3.2",
"windows-release": "^5.1.0",
"winston": "2.4.4",
Expand Down

0 comments on commit 010d90b

Please sign in to comment.