diff options
Diffstat (limited to 'node_modules/update-notifier/index.js')
-rw-r--r-- | node_modules/update-notifier/index.js | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/node_modules/update-notifier/index.js b/node_modules/update-notifier/index.js index 0a11dbf1f..a5fff0103 100644 --- a/node_modules/update-notifier/index.js +++ b/node_modules/update-notifier/index.js @@ -2,20 +2,21 @@ const spawn = require('child_process').spawn; const path = require('path'); const format = require('util').format; -const lazyRequire = require('lazy-req')(require); - -const configstore = lazyRequire('configstore'); -const chalk = lazyRequire('chalk'); -const semverDiff = lazyRequire('semver-diff'); -const latestVersion = lazyRequire('latest-version'); -const isNpm = lazyRequire('is-npm'); -const boxen = lazyRequire('boxen'); -const xdgBasedir = lazyRequire('xdg-basedir'); +const importLazy = require('import-lazy')(require); + +const configstore = importLazy('configstore'); +const chalk = importLazy('chalk'); +const semverDiff = importLazy('semver-diff'); +const latestVersion = importLazy('latest-version'); +const isNpm = importLazy('is-npm'); +const boxen = importLazy('boxen'); +const xdgBasedir = importLazy('xdg-basedir'); const ONE_DAY = 1000 * 60 * 60 * 24; class UpdateNotifier { constructor(options) { - this.options = options = options || {}; + options = options || {}; + this.options = options; options.pkg = options.pkg || {}; // Reduce pkg to the essential keys. with fallback to deprecated options @@ -34,8 +35,10 @@ class UpdateNotifier { this.updateCheckInterval = typeof options.updateCheckInterval === 'number' ? options.updateCheckInterval : ONE_DAY; this.hasCallback = typeof options.callback === 'function'; this.callback = options.callback || (() => {}); + this.disabled = 'NO_UPDATE_NOTIFIER' in process.env || + process.argv.indexOf('--no-update-notifier') !== -1; - if (!this.hasCallback) { + if (!this.disabled && !this.hasCallback) { try { const ConfigStore = configstore(); this.config = new ConfigStore(`update-notifier-${this.packageName}`, { @@ -69,8 +72,7 @@ class UpdateNotifier { if ( !this.config || this.config.get('optOut') || - 'NO_UPDATE_NOTIFIER' in process.env || - process.argv.indexOf('--no-update-notifier') !== -1 + this.disabled ) { return; } |