Skip to content

Commit

Permalink
config: Enable config for suppressing update-notifier (#20750)
Browse files Browse the repository at this point in the history
PR-URL: npm/npm#20750
Credit: @travi
Reviewed By: @zkat
  • Loading branch information
travi authored and zkat committed Jun 28, 2018
1 parent 2d08866 commit ce07933
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bin/npm-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@
conf._exit = true
npm.load(conf, function (er) {
if (er) return errorHandler(er)
if (!unsupported.checkVersion(process.version).unsupported) {
if (
npm.config.get('update-notifier') &&
!unsupported.checkVersion(process.version).unsupported
) {
const pkg = require('../package.json')
let notifier = require('update-notifier')({pkg})
if (
Expand Down
8 changes: 8 additions & 0 deletions doc/misc/npm-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,14 @@ Set to true to suppress the UID/GID switching when running package
scripts. If set explicitly to false, then installing as a non-root user
will fail.

### update-notifier

* Default: true
* Type: Boolean

Set to false to suppress the update notification when using an older
version of npm than the latest.

### usage

* Default: false
Expand Down
2 changes: 2 additions & 0 deletions lib/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ Object.defineProperty(exports, 'defaults', {get: function () {
!(process.getuid && process.setuid &&
process.getgid && process.setgid) ||
process.getuid() !== 0,
'update-notifier': true,
usage: false,
user: process.platform === 'win32' ? 0 : 'nobody',
userconfig: path.resolve(home, '.npmrc'),
Expand Down Expand Up @@ -360,6 +361,7 @@ exports.types = {
tmp: path,
unicode: Boolean,
'unsafe-perm': Boolean,
'update-notifier': Boolean,
usage: Boolean,
user: [Number, String],
userconfig: path,
Expand Down
2 changes: 2 additions & 0 deletions test/tap/config-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var fs = require('fs')
var path = require('path')
var root = path.resolve(__dirname, '..', '..')
var lib = path.resolve(root, 'lib')
var bin = path.resolve(root, 'bin')
var nm = path.resolve(root, 'node_modules')
var doc = path.resolve(root, 'doc/misc/npm-config.md')
var FILES = []
Expand All @@ -31,6 +32,7 @@ var exceptions = [
test('get files', function (t) {
walk(nm)
walk(lib)
walk(bin)
t.pass('got files')
t.end()

Expand Down

0 comments on commit ce07933

Please sign in to comment.