Skip to content

Commit

Permalink
Replace _.set with native property assignment statement
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericbarthelet committed Jan 4, 2021
1 parent cf7b25e commit 54dda0f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/classes/PluginManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class PluginManager {
if (commands) {
Object.entries(commands).forEach(([name, command]) => {
if (command.type !== 'entrypoint') {
_.set(target, name, _.omit(command, 'commands'));
target[name] = _.omit(command, 'commands');
if (
Object.values(command.commands).some(
(childCommand) => childCommand.type !== 'entrypoint'
Expand All @@ -400,7 +400,7 @@ class PluginManager {
}
if (alias.command) {
const commandPath = alias.command.split(':').join('.commands.');
_.set(target, name, _.get(this.commands, commandPath));
target[name] = _.get(this.commands, commandPath);
} else {
target[name] = target[name] || {};
target[name].commands = target[name].commands || {};
Expand Down
3 changes: 1 addition & 2 deletions test/unit/lib/classes/PluginManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const Serverless = require('../../../../lib/Serverless');
const CLI = require('../../../../lib/classes/CLI');
const Create = require('../../../../lib/plugins/create/create');

const _ = require('lodash');
const path = require('path');
const fs = require('fs');
const fse = require('fs-extra');
Expand Down Expand Up @@ -989,7 +988,7 @@ describe('PluginManager', () => {
const consoleLogStub = sinon.stub(pluginManager.serverless.cli, 'log').returns();
const synchronousPluginMockInstance = new SynchronousPluginMock();
synchronousPluginMockInstance.commands.deploy.aliases = ['info'];
_.set(process.env, 'SLS_DEBUG', '*');
process.env.SLS_DEBUG = '*';
pluginManager.loadCommands(synchronousPluginMockInstance);
expect(consoleLogStub).to.have.been.calledWith(' -> @info');
});
Expand Down
8 changes: 3 additions & 5 deletions test/unit/lib/plugins/aws/package/compile/functions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1129,11 +1129,9 @@ describe('AwsCompileFunctions', () => {
Outputs: {},
};

_.set(
awsCompileFunctions,
'serverless.service.functions.func.environment.MY_ENV_VAR',
'myvalue'
);
awsCompileFunctions.serverless.service.functions.func.environment = {
MY_ENV_VAR: 'myvalue',
};

return expect(awsCompileFunctions.compileFunctions()).to.be.fulfilled;
})
Expand Down

0 comments on commit 54dda0f

Please sign in to comment.