xcraft-core-utils 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/modules.js +9 -3
  2. package/package.json +1 -1
package/lib/modules.js CHANGED
@@ -5,6 +5,12 @@ const fse = require('fs-extra');
5
5
  const xFs = require('xcraft-core-fs');
6
6
  const _ = require('lodash');
7
7
 
8
+ function merge(obj, overloads) {
9
+ _.mergeWith(obj, overloads, (_, src) =>
10
+ Array.isArray(src) && src.length === 0 ? [] : undefined
11
+ );
12
+ }
13
+
8
14
  function applyOverloads(appDir, appId, variantId, app) {
9
15
  if (!variantId) {
10
16
  return;
@@ -14,7 +20,7 @@ function applyOverloads(appDir, appId, variantId, app) {
14
20
  const overloads = JSON.parse(
15
21
  fse.readFileSync(path.join(appDir, appId, `app.${variantId}.json`))
16
22
  );
17
- _.merge(app.xcraft, overloads);
23
+ merge(app.xcraft, overloads);
18
24
  } catch (ex) {
19
25
  if (ex.code !== 'ENOENT') {
20
26
  throw ex;
@@ -47,10 +53,10 @@ exports.extractForEtc = (appDir, appId, variantId) => {
47
53
  fse.readFileSync(path.join(appDir, appId, 'app.json'))
48
54
  );
49
55
  applyOverloads(appDir, appId, variantId, appConfig);
50
- _.merge(app.xcraft[mod.moduleName], appConfig.xcraft[mod.moduleName]);
56
+ merge(app.xcraft[mod.moduleName], appConfig.xcraft[mod.moduleName]);
51
57
  });
52
58
 
53
- _.merge(app.xcraft[mod.moduleName], userOverloads);
59
+ merge(app.xcraft[mod.moduleName], userOverloads);
54
60
  delete app.xcraft[`${mod.moduleName}@${mod.fullAppId}`];
55
61
  });
56
62
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xcraft-core-utils",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "description": "Xcraft utils",
5
5
  "main": "index.js",
6
6
  "engines": {