Skip to content

Commit

Permalink
chore: Update update-notifier
Browse files Browse the repository at this point in the history
Fixes serverless#7486

Bump update-notifier to the current version to resolve security alerts.
However, don't load in Node.js 6 because the current version is only
supported in Node.js 8 and above. The serverless package will still work
in Node.js 6, but it will not alert people when an upgrade is available.
  • Loading branch information
Trott committed Aug 8, 2020
1 parent 4660acd commit 6d7e40d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lib/Serverless.js
Expand Up @@ -5,7 +5,11 @@ const BbPromise = require('bluebird');
const os = require('os');
const chalk = require('chalk');
const ensureString = require('type/string/ensure');
const updateNotifier = require('update-notifier');

// Only load update-notifier in Node.js 8 and above. The version used here may
// not work in Node.js 6 and the versions that do work result in security
// alerts.
const updateNotifier = +process.versions.node.split('.')[0] < 8 ? null : require('update-notifier');
const pkg = require('../package.json');
const CLI = require('./classes/CLI');
const Config = require('./classes/Config');
Expand Down Expand Up @@ -79,7 +83,10 @@ class Serverless {
this.pluginManager.setCliOptions(this.processedInput.options);
this.pluginManager.setCliCommands(this.processedInput.commands);

if (!installationMaintananceCommands.has(this.processedInput.commands[0])) {
if (
updateNotifier &&
!installationMaintananceCommands.has(this.processedInput.commands[0])
) {
// Check if update is available
const notifier = updateNotifier({ pkg });
notifier.notify({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -72,7 +72,7 @@
"tabtab": "^3.0.2",
"type": "^2.0.0",
"untildify": "^3.0.3",
"update-notifier": "^2.5.0",
"update-notifier": "^4.1.0",
"uuid": "^3.4.0",
"write-file-atomic": "^2.4.3",
"yaml-ast-parser": "0.0.43",
Expand Down

0 comments on commit 6d7e40d

Please sign in to comment.