Skip to content

Commit 975fc16

Browse files
Merge pull request #1263 from opencomponents/remove-lodash-extend
[INTERNAL] Replace usage of lodash _.extend with Object.assign
2 parents 89997b9 + b685938 commit 975fc16

File tree

9 files changed

+25
-30
lines changed

9 files changed

+25
-30
lines changed

src/cli/domain/registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export default function registry(opts: RegistryOptions = {}): RegistryCli {
123123
callback: Callback<unknown, string>
124124
) {
125125
if (!!options.username && !!options.password) {
126-
requestsHeaders = _.extend(requestsHeaders, {
126+
requestsHeaders = Object.assign(requestsHeaders, {
127127
Authorization:
128128
'Basic ' +
129129
new Buffer(options.username + ':' + options.password).toString(

src/cli/facade/publish.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const publish =
111111
logger.warn(strings.messages.cli.REGISTRY_CREDENTIALS_REQUIRED);
112112

113113
return getCredentials((_err, credentials) => {
114-
putComponentToRegistry(_.extend(options, credentials), cb);
114+
putComponentToRegistry(Object.assign(options, credentials), cb);
115115
});
116116
} else if ((err as any).code === 'cli_version_not_valid') {
117117
const upgradeCommand = strings.commands.cli.UPGRADE(

src/registry/domain/repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export default function repository(conf: Config): Repository {
184184
null as any
185185
);
186186
}
187-
callback(null, _.extend(component, { allVersions }));
187+
callback(null, Object.assign(component, { allVersions }));
188188
}
189189
);
190190
});
@@ -362,7 +362,7 @@ export default function repository(conf: Config): Repository {
362362
}
363363

364364
const validationResult = validator.validatePackageJson(
365-
_.extend(pkgDetails, {
365+
Object.assign(pkgDetails, {
366366
componentName,
367367
customValidator: conf.publishValidation
368368
})

src/registry/routes/components.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default function components(
7272
headers: req.headers,
7373
ip: req.ip,
7474
omitHref: !!req.body.omitHref,
75-
parameters: _.extend({}, req.body.parameters, component.parameters),
75+
parameters: { ...req.body.parameters, ...component.parameters },
7676
version: component.version
7777
},
7878
result => callback(null, result)

src/registry/routes/helpers/get-component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ export default function getComponent(conf: Config, repository: Repository) {
317317
callback({
318318
status: 200,
319319
headers: responseHeaders,
320-
response: _.extend(response, {
320+
response: Object.assign(response, {
321321
data: data,
322322
template: {
323323
src: repository.getStaticFilePath(
@@ -363,7 +363,7 @@ export default function getComponent(conf: Config, repository: Repository) {
363363
callback({
364364
status: 200,
365365
headers: responseHeaders,
366-
response: _.extend(response, { html })
366+
response: Object.assign(response, { html })
367367
});
368368
}
369369
);

test/acceptance/registry.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const expect = require('chai').expect;
44
const emptyResponseHandler = require('oc-empty-response-handler');
55
const path = require('path');
66
const request = require('minimal-request');
7-
const _ = require('lodash');
87

98
describe('registry', () => {
109
let registry;
@@ -111,9 +110,10 @@ describe('registry', () => {
111110
before(done => {
112111
registry.close();
113112
initializeRegistry(
114-
_.extend(getDefaultTestConfiguration(), {
113+
{
114+
...getDefaultTestConfiguration(),
115115
customHeadersToSkipOnWeakVersion: ['Cache-Control']
116-
}),
116+
},
117117
done
118118
);
119119
});
@@ -273,9 +273,10 @@ describe('registry', () => {
273273
before(done => {
274274
registry.close();
275275
initializeRegistry(
276-
_.extend(getDefaultTestConfiguration(), {
276+
{
277+
...getDefaultTestConfiguration(),
277278
customHeadersToSkipOnWeakVersion: ['Cache-Control']
278-
}),
279+
},
279280
done
280281
);
281282
});

test/integration/targz.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const expect = require('chai').expect;
44
const fs = require('fs-extra');
55
const path = require('path');
66
const targz = require('targz');
7-
const _ = require('lodash');
87

98
describe('The targz dependency', () => {
109
describe('when compressing a folder with targz', () => {
@@ -21,9 +20,7 @@ describe('The targz dependency', () => {
2120
dest: file,
2221
tar: {
2322
map: function (fileName) {
24-
return _.extend(fileName, {
25-
name: 'hello-world/' + fileName.name
26-
});
23+
return { ...fileName, name: 'hello-world/' + fileName.name };
2724
}
2825
}
2926
},

test/unit/cli-domain-get-mocked-plugins.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@ describe('cli : domain : get-mocked-plugins', () => {
1818
let getMockedPlugins;
1919

2020
const initialise = function (fs, pathJoinStub) {
21-
fsMock = _.extend(
22-
{
23-
existsSync: sinon.stub().returns(true),
24-
readFileSync: sinon.stub().returns('file content'),
25-
readJsonSync: sinon.stub().returns({ content: true }),
26-
realpathSync: sinon.stub().returns('/root/'),
27-
writeFile: sinon.stub().yields(null, 'ok')
28-
},
29-
fs || {}
30-
);
21+
fsMock = {
22+
existsSync: sinon.stub().returns(true),
23+
readFileSync: sinon.stub().returns('file content'),
24+
readJsonSync: sinon.stub().returns({ content: true }),
25+
realpathSync: sinon.stub().returns('/root/'),
26+
writeFile: sinon.stub().yields(null, 'ok'),
27+
...fs
28+
};
3129

3230
const fakePathFunc = function () {
3331
return _.toArray(arguments)

test/unit/registry-domain-repository.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const fs = require('fs-extra');
55
const injectr = require('injectr');
66
const path = require('path');
77
const sinon = require('sinon');
8-
const _ = require('lodash');
98

109
describe('registry : domain : repository', () => {
1110
let response;
@@ -150,7 +149,7 @@ describe('registry : domain : repository', () => {
150149

151150
describe('when the templates specificed on the configuaration are core-templates', () => {
152151
it('should only return uniques templates', () => {
153-
const conf = _.extend(cdnConfiguration, {
152+
const conf = Object.assign(cdnConfiguration, {
154153
templates: [require('oc-template-jade')]
155154
});
156155
const repository = Repository(conf);
@@ -161,7 +160,7 @@ describe('registry : domain : repository', () => {
161160
describe('when templates specificed on the configuaration are not installed', () => {
162161
it('should throw an error', () => {
163162
try {
164-
const conf = _.extend(cdnConfiguration, {
163+
const conf = Object.assign(cdnConfiguration, {
165164
templates: [require('oc-template-react')]
166165
});
167166
Repository(conf);
@@ -360,7 +359,7 @@ describe('registry : domain : repository', () => {
360359
s3Mock.putDir = sinon.stub();
361360
s3Mock.putDir.yields(null, 'done');
362361
repository.publishComponent(
363-
_.extend(pkg, {
362+
Object.assign(pkg, {
364363
outputFolder: '/path/to/component',
365364
componentName: 'hello-world'
366365
}),

0 commit comments

Comments
 (0)