Просмотр исходного кода

fix(config): override config values instead of merging

Iterate over objects and copy over primitives and arrays
instead of using _.merge, as merge will not replace a config
entry completely. For arrays in a target object, the arrays
will have its indices replaced. This means if a source array
is empty, the target array will be left alone. Similarly,
if the target array is longer than a source array, there
will be indices not touched in the target array.
master
Leonard Kim 7 лет назад
Родитель
Сommit
5358f022ff
1 измененных файлов: 10 добавлений и 3 удалений
  1. 10
    3
      react/features/base/config/functions.js

+ 10
- 3
react/features/base/config/functions.js Просмотреть файл

@@ -175,9 +175,16 @@ export function overrideConfigJSON(
175 175
 
176 176
             if (!_.isEmpty(configJSON)) {
177 177
                 logger.info(
178
-                    `Extending ${configName} `
179
-                    + `with: ${JSON.stringify(configJSON)}`);
180
-                _.merge(configObj, configJSON);
178
+                    `Extending ${configName} with: ${
179
+                        JSON.stringify(configJSON)}`);
180
+
181
+                // eslint-disable-next-line arrow-body-style
182
+                _.mergeWith(configObj, configJSON, (oldValue, newValue) => {
183
+
184
+                    // XXX We don't want to merge the arrays, we want to
185
+                    // overwrite them.
186
+                    return Array.isArray(oldValue) ? newValue : undefined;
187
+                });
181 188
             }
182 189
         }
183 190
     }

Загрузка…
Отмена
Сохранить