Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

Commit ce07933

Browse files
travizkat
authored andcommitted
config: Enable config for suppressing update-notifier (#20750)
PR-URL: #20750 Credit: @travi Reviewed By: @zkat
1 parent 2d08866 commit ce07933

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

bin/npm-cli.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@
7474
conf._exit = true
7575
npm.load(conf, function (er) {
7676
if (er) return errorHandler(er)
77-
if (!unsupported.checkVersion(process.version).unsupported) {
77+
if (
78+
npm.config.get('update-notifier') &&
79+
!unsupported.checkVersion(process.version).unsupported
80+
) {
7881
const pkg = require('../package.json')
7982
let notifier = require('update-notifier')({pkg})
8083
if (

doc/misc/npm-config.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,14 @@ Set to true to suppress the UID/GID switching when running package
11301130
scripts. If set explicitly to false, then installing as a non-root user
11311131
will fail.
11321132

1133+
### update-notifier
1134+
1135+
* Default: true
1136+
* Type: Boolean
1137+
1138+
Set to false to suppress the update notification when using an older
1139+
version of npm than the latest.
1140+
11331141
### usage
11341142

11351143
* Default: false

lib/config/defaults.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ Object.defineProperty(exports, 'defaults', {get: function () {
234234
!(process.getuid && process.setuid &&
235235
process.getgid && process.setgid) ||
236236
process.getuid() !== 0,
237+
'update-notifier': true,
237238
usage: false,
238239
user: process.platform === 'win32' ? 0 : 'nobody',
239240
userconfig: path.resolve(home, '.npmrc'),
@@ -360,6 +361,7 @@ exports.types = {
360361
tmp: path,
361362
unicode: Boolean,
362363
'unsafe-perm': Boolean,
364+
'update-notifier': Boolean,
363365
usage: Boolean,
364366
user: [Number, String],
365367
userconfig: path,

test/tap/config-meta.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var fs = require('fs')
99
var path = require('path')
1010
var root = path.resolve(__dirname, '..', '..')
1111
var lib = path.resolve(root, 'lib')
12+
var bin = path.resolve(root, 'bin')
1213
var nm = path.resolve(root, 'node_modules')
1314
var doc = path.resolve(root, 'doc/misc/npm-config.md')
1415
var FILES = []
@@ -31,6 +32,7 @@ var exceptions = [
3132
test('get files', function (t) {
3233
walk(nm)
3334
walk(lib)
35+
walk(bin)
3436
t.pass('got files')
3537
t.end()
3638

0 commit comments

Comments
 (0)