Skip to content

Commit 321e95f

Browse files
committed
Refactor: remove lodash.merge
1 parent 963dbf3 commit 321e95f

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

lib/mapping/generateMapping.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { fromCallback } from 'universalify';
2-
import merge from 'lodash.merge';
1+
import { fromPromise } from 'universalify';
32
import rcs from 'rcs-core';
43
import path from 'path';
54
import json from 'json-extra';
@@ -24,26 +23,23 @@ const generateMapping = (
2423
let fileNameExt = '.json';
2524
let mappingName = 'CSS_NAME_MAPPING';
2625

27-
const optionsDefault: GenerateMappingOptions = {
26+
const options: GenerateMappingOptions = {
2827
cssMapping: true,
2928
cssMappingMin: false,
3029
json: true,
3130
origValues: true,
3231
isSelectors: true,
3332
overwrite: false,
33+
...opts,
3434
};
3535

36-
let options = opts;
3736
let callback = cb;
3837

3938
// set cb if options are not set
4039
if (typeof callback !== 'function') {
4140
callback = options as () => void;
42-
options = {};
4341
}
4442

45-
options = merge({}, optionsDefault, options);
46-
4743
if (options.cssMappingMin) {
4844
options.origValues = false;
4945
mappingName = 'CSS_NAME_MAPPING_MIN';
@@ -83,4 +79,4 @@ const generateMapping = (
8379
});
8480
}; // /generateMapping
8581

86-
export default fromCallback(generateMapping);
82+
export default fromPromise(generateMapping);

lib/process/processSync.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import merge from 'lodash.merge';
21
import fs from 'fs';
32
import rcs from 'rcs-core';
43
import path from 'path';
@@ -23,7 +22,7 @@ function processSync(type: 'pug', pathString: string | string[], opts?: AllOptio
2322
function processSync(type: 'any', pathString: string | string[], opts?: AllOptions['any']): void;
2423
function processSync(type: any, pathString: string | string[], opts: any = {}): void {
2524
let globString: string;
26-
const options = merge({}, optionsDefault, opts);
25+
const options = { ...optionsDefault, ...opts };
2726

2827
assert(
2928
availableTypes.includes(type),

package-lock.json

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
"fs-extra": "^8.1.0",
5151
"glob": "^7.1.6",
5252
"json-extra": "^0.5.0",
53-
"lodash.merge": "^4.6.2",
5453
"universalify": "^0.1.2"
5554
},
5655
"peerDependencies": {

0 commit comments

Comments
 (0)