config 3.3.10 → 3.3.12
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.
- package/lib/config.js +3 -4
- package/package.json +1 -1
- package/parser.js +17 -9
package/lib/config.js
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
const DeferredConfig = require('../defer').DeferredConfig;
|
|
8
8
|
const RawConfig = require('../raw').RawConfig;
|
|
9
9
|
let Parser = require('../parser');
|
|
10
|
-
const Utils = require('util');
|
|
11
10
|
const Path = require('path');
|
|
12
11
|
const FileSystem = require('fs');
|
|
13
12
|
|
|
@@ -1003,12 +1002,12 @@ util.cloneDeep = function cloneDeep(parent, depth, circular, prototype) {
|
|
|
1003
1002
|
return parent;
|
|
1004
1003
|
}
|
|
1005
1004
|
|
|
1006
|
-
if (
|
|
1005
|
+
if (Array.isArray(parent)) {
|
|
1007
1006
|
child = [];
|
|
1008
|
-
} else if (
|
|
1007
|
+
} else if (parent instanceof RegExp) {
|
|
1009
1008
|
child = new RegExp(parent.source, util.getRegExpFlags(parent));
|
|
1010
1009
|
if (parent.lastIndex) child.lastIndex = parent.lastIndex;
|
|
1011
|
-
} else if (
|
|
1010
|
+
} else if (parent instanceof Date) {
|
|
1012
1011
|
child = new Date(parent.getTime());
|
|
1013
1012
|
} else if (useBuffer && Buffer.isBuffer(parent)) {
|
|
1014
1013
|
child = Buffer.alloc(parent.length);
|
package/package.json
CHANGED
package/parser.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
// External libraries are lazy-loaded only if these file types exist.
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
// webpack can't solve dynamic module
|
|
4
|
+
// @see https://github.com/node-config/node-config/issues/755
|
|
5
|
+
// @see https://webpack.js.org/guides/dependency-management/#require-with-expression
|
|
6
|
+
const JSON5Module = require('json5');
|
|
7
|
+
|
|
8
|
+
// webpack resolves json5 with module field out of the box which lead to this usage
|
|
9
|
+
// @see https://github.com/node-config/node-config/issues/755
|
|
10
|
+
// @see https://github.com/json5/json5/issues/240
|
|
11
|
+
const JSON5 = JSON5Module.default || JSON5Module;
|
|
12
|
+
|
|
3
13
|
var Yaml = null,
|
|
4
14
|
VisionmediaYaml = null,
|
|
5
15
|
Coffee = null,
|
|
6
16
|
Iced = null,
|
|
7
17
|
CSON = null,
|
|
8
18
|
PPARSER = null,
|
|
9
|
-
JSON5 = null,
|
|
10
19
|
TOML = null,
|
|
11
20
|
HJSON = null,
|
|
12
21
|
XML = null;
|
|
@@ -51,7 +60,7 @@ Parser.xmlParser = function(filename, content) {
|
|
|
51
60
|
Parser.jsParser = function(filename, content) {
|
|
52
61
|
var configObject = require(filename);
|
|
53
62
|
|
|
54
|
-
if (configObject.__esModule &&
|
|
63
|
+
if (configObject.__esModule && isObject(configObject.default)) {
|
|
55
64
|
return configObject.default
|
|
56
65
|
}
|
|
57
66
|
return configObject;
|
|
@@ -160,15 +169,10 @@ Parser.jsonParser = function(filename, content) {
|
|
|
160
169
|
* This is due to issues with removing supported comments.
|
|
161
170
|
* More information can be found here: https://github.com/node-config/node-config/issues/715
|
|
162
171
|
*/
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return JSON5.parse(content);
|
|
172
|
+
return JSON5.parse(content);
|
|
166
173
|
};
|
|
167
174
|
|
|
168
175
|
Parser.json5Parser = function(filename, content) {
|
|
169
|
-
if (!JSON5) {
|
|
170
|
-
JSON5 = require(JSON5_DEP);
|
|
171
|
-
}
|
|
172
176
|
return JSON5.parse(content);
|
|
173
177
|
};
|
|
174
178
|
|
|
@@ -361,3 +365,7 @@ Parser.setFilesOrder = function(name, newIndex) {
|
|
|
361
365
|
}
|
|
362
366
|
return order;
|
|
363
367
|
};
|
|
368
|
+
|
|
369
|
+
function isObject(arg) {
|
|
370
|
+
return (arg !== null) && (typeof arg === 'object');
|
|
371
|
+
}
|