Skip to content

Commit 3f7fe17

Browse files
lukekarrysfritzy
authored andcommitted
fix: skip update notifier file if not requested
1 parent 877138e commit 3f7fe17

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/utils/update-notifier.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const stat = promisify(require('fs').stat)
1111
const writeFile = promisify(require('fs').writeFile)
1212
const { resolve } = require('path')
1313

14+
const SKIP = Symbol('SKIP')
15+
1416
const isGlobalNpmUpdate = npm => {
1517
return npm.flatOptions.global &&
1618
['install', 'update'].includes(npm.command) &&
@@ -38,7 +40,7 @@ const updateNotifier = async (npm, spec = 'latest') => {
3840
if (!npm.config.get('update-notifier') ||
3941
isGlobalNpmUpdate(npm) ||
4042
ciDetect()) {
41-
return null
43+
return SKIP
4244
}
4345

4446
// if we're on a prerelease train, then updates are coming fast
@@ -118,6 +120,12 @@ const updateNotifier = async (npm, spec = 'latest') => {
118120
// only update the notification timeout if we actually finished checking
119121
module.exports = async npm => {
120122
const notification = await updateNotifier(npm)
123+
124+
// dont write the file if we skipped checking altogether
125+
if (notification === SKIP) {
126+
return null
127+
}
128+
121129
// intentional. do not await this. it's a best-effort update. if this
122130
// fails, it's ok. might be using /dev/null as the cache or something weird
123131
// like that.

0 commit comments

Comments
 (0)