From e4153f231dd443459de762826f02842fa9f5b083 Mon Sep 17 00:00:00 2001 From: Aditya Samantaray Date: Tue, 2 Jul 2024 16:55:13 +0530 Subject: [PATCH 1/2] chore: bump the version of update-notifier --- bin/commands/runs.js | 38 ++++++++++++++++++++------------------ package.json | 2 +- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/bin/commands/runs.js b/bin/commands/runs.js index d2c4aa5c..812a2971 100644 --- a/bin/commands/runs.js +++ b/bin/commands/runs.js @@ -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'); @@ -531,23 +530,26 @@ 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, - }); - - // 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(); - } + 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(); + } - // 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); + }); }); } diff --git a/package.json b/package.json index 158e593f..b6dd08da 100644 --- a/package.json +++ b/package.json @@ -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", From 3cd2cf27e50f7b57097779bcdef8566d1efc8dbf Mon Sep 17 00:00:00 2001 From: Aditya Samantaray Date: Tue, 2 Jul 2024 16:56:55 +0530 Subject: [PATCH 2/2] refactor: minor space changes --- bin/commands/runs.js | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/commands/runs.js b/bin/commands/runs.js index 812a2971..960e8bfd 100644 --- a/bin/commands/runs.js +++ b/bin/commands/runs.js @@ -535,6 +535,7 @@ module.exports = function run(args, rawArgs) { 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.