diff options
author | Luke Karrys <luke@lukekarrys.com> | 2022-04-08 18:21:29 +0300 |
---|---|---|
committer | Nathan Fritz <fritzy@github.com> | 2022-04-14 00:20:48 +0300 |
commit | 3f7fe17d1ea743b3ce1f27b9156e9fa0e358a7df (patch) | |
tree | d7ed2150bb7973557093c758d0b8df851e7953cc /lib | |
parent | 877138eb4d1c4470c4164fc6e057d082b120fb05 (diff) |
fix: skip update notifier file if not requested
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils/update-notifier.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/utils/update-notifier.js b/lib/utils/update-notifier.js index dde0202b7..75e944407 100644 --- a/lib/utils/update-notifier.js +++ b/lib/utils/update-notifier.js @@ -11,6 +11,8 @@ const stat = promisify(require('fs').stat) const writeFile = promisify(require('fs').writeFile) const { resolve } = require('path') +const SKIP = Symbol('SKIP') + const isGlobalNpmUpdate = npm => { return npm.flatOptions.global && ['install', 'update'].includes(npm.command) && @@ -38,7 +40,7 @@ const updateNotifier = async (npm, spec = 'latest') => { if (!npm.config.get('update-notifier') || isGlobalNpmUpdate(npm) || ciDetect()) { - return null + return SKIP } // if we're on a prerelease train, then updates are coming fast @@ -118,6 +120,12 @@ const updateNotifier = async (npm, spec = 'latest') => { // only update the notification timeout if we actually finished checking module.exports = async npm => { const notification = await updateNotifier(npm) + + // dont write the file if we skipped checking altogether + if (notification === SKIP) { + return null + } + // intentional. do not await this. it's a best-effort update. if this // fails, it's ok. might be using /dev/null as the cache or something weird // like that. |