Skip to content

Commit

Permalink
refactor(CLI): Modern logs for config command
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrzesik committed Oct 4, 2021
1 parent 0c9dae1 commit 7926570
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions lib/plugins/config.js
Expand Up @@ -9,6 +9,7 @@ const tabtabOptions = require('../utils/tabCompletion/tabtabOptions');
const isNpmPackageWritable = require('../utils/npmPackage/isWritable');
const isNpmGlobalPackage = require('../utils/npmPackage/isGlobal');
const renderCommandHelp = require('../cli/render-help/command');
const { legacy, log } = require('@serverless/utils/log');

// class wide constants
const validProviders = new Set(['aws']);
Expand Down Expand Up @@ -80,7 +81,9 @@ class Config {
}
if (this.options.autoupdate) {
if (config.get('autoUpdate.enabled')) {
this.serverless.cli.log('Auto update is already turned on');
const message = 'Auto update is already turned on';
legacy.log(message);
log.notice.skip(message);
return;
}
if (this.serverless.isLocallyInstalled) {
Expand All @@ -103,18 +106,22 @@ class Config {
}
config.set('autoUpdate.enabled', true);

this.serverless.cli.log(
'Auto update successfully turned on (Turn off at any time with "serverless config --no-autoupdate")'
);
const message =
'Auto update successfully turned on (Turn off at any time with "serverless config --no-autoupdate")';
legacy.log(message);
log.notice.success(message);
} else {
if (!config.get('autoUpdate.enabled')) {
this.serverless.cli.log('Auto update is already turned off');
const message = 'Auto update is already turned off';
legacy.log(message);
log.notice.skip(message);
return;
}
config.set('autoUpdate.enabled', false);
this.serverless.cli.log(
'Auto update successfully turned off (Turn on at any time with "serverless config --autoupdate")'
);
const message =
'Auto update successfully turned off (Turn on at any time with "serverless config --autoupdate")';
legacy.log(message);
log.notice.success(message);
}
}

Expand Down

0 comments on commit 7926570

Please sign in to comment.