config 3.3.2 → 3.3.3
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/History.md +8 -0
- package/lib/config.js +23 -8
- package/package.json +1 -1
- package/parser.js +2 -1
package/History.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
3.3.3 / 2020-11-26
|
|
2
|
+
==================
|
|
3
|
+
|
|
4
|
+
* FIX #460 - Strict mode warning refer to appropriate env variable @iCodeOkay
|
|
5
|
+
* Use Buffer.alloc and Buffer.from instead of contrsuctor @Fcmam5
|
|
6
|
+
* Add support for experimental .cjs modules @lenkan
|
|
7
|
+
|
|
8
|
+
|
|
1
9
|
3.3.2 / 2020-09-24
|
|
2
10
|
==================
|
|
3
11
|
|
package/lib/config.js
CHANGED
|
@@ -15,7 +15,7 @@ var deferConfig = require('../defer').deferConfig,
|
|
|
15
15
|
// Static members
|
|
16
16
|
var DEFAULT_CLONE_DEPTH = 20,
|
|
17
17
|
NODE_CONFIG, CONFIG_DIR, RUNTIME_JSON_FILENAME, NODE_ENV, APP_INSTANCE,
|
|
18
|
-
HOST, HOSTNAME, ALLOW_CONFIG_MUTATIONS, CONFIG_SKIP_GITCRYPT,
|
|
18
|
+
HOST, HOSTNAME, ALLOW_CONFIG_MUTATIONS, CONFIG_SKIP_GITCRYPT, NODE_ENV_VAR_NAME,
|
|
19
19
|
NODE_CONFIG_PARSER,
|
|
20
20
|
env = {},
|
|
21
21
|
privateUtil = {},
|
|
@@ -513,11 +513,26 @@ util.loadFileConfigs = function(configDir) {
|
|
|
513
513
|
var t = this,
|
|
514
514
|
config = {};
|
|
515
515
|
|
|
516
|
-
//
|
|
517
|
-
|
|
516
|
+
// Specify variables that can be used to define the environment
|
|
517
|
+
var node_env_var_names = ['NODE_CONFIG_ENV', 'NODE_ENV'];
|
|
518
518
|
|
|
519
|
-
//
|
|
520
|
-
|
|
519
|
+
// Loop through the variables to try and set environment
|
|
520
|
+
for (node_env_var_name of node_env_var_names) {
|
|
521
|
+
NODE_ENV = util.initParam(node_env_var_name);
|
|
522
|
+
if (!!NODE_ENV) {
|
|
523
|
+
NODE_ENV_VAR_NAME = node_env_var_name;
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// If we haven't successfully set the environment using the variables, we'll default it
|
|
529
|
+
if (!NODE_ENV) {
|
|
530
|
+
NODE_ENV = 'development';
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
node_env_var_names.forEach(node_env_var_name => {
|
|
534
|
+
env[node_env_var_name] = NODE_ENV;
|
|
535
|
+
});
|
|
521
536
|
|
|
522
537
|
// Split files name, for loading multiple files.
|
|
523
538
|
NODE_ENV = NODE_ENV.split(',');
|
|
@@ -952,7 +967,7 @@ util.cloneDeep = function cloneDeep(parent, depth, circular, prototype) {
|
|
|
952
967
|
} else if (Utils.isDate(parent)) {
|
|
953
968
|
child = new Date(parent.getTime());
|
|
954
969
|
} else if (useBuffer && Buffer.isBuffer(parent)) {
|
|
955
|
-
child =
|
|
970
|
+
child = Buffer.alloc(parent.length);
|
|
956
971
|
parent.copy(child);
|
|
957
972
|
return child;
|
|
958
973
|
} else {
|
|
@@ -1409,11 +1424,11 @@ util.runStrictnessChecks = function (config) {
|
|
|
1409
1424
|
});
|
|
1410
1425
|
// development is special-cased because it's the default value
|
|
1411
1426
|
if (env && (env !== 'development') && !anyFilesMatchEnv) {
|
|
1412
|
-
_warnOrThrow("
|
|
1427
|
+
_warnOrThrow(NODE_ENV_VAR_NAME+" value of '"+env+"' did not match any deployment config file names.");
|
|
1413
1428
|
}
|
|
1414
1429
|
// Throw if NODE_ENV matches' default' or 'local'
|
|
1415
1430
|
if ((env === 'default') || (env === 'local')) {
|
|
1416
|
-
_warnOrThrow("
|
|
1431
|
+
_warnOrThrow(NODE_ENV_VAR_NAME+" value of '"+env+"' is ambiguous.");
|
|
1417
1432
|
}
|
|
1418
1433
|
});
|
|
1419
1434
|
|
package/package.json
CHANGED
package/parser.js
CHANGED
|
@@ -304,9 +304,10 @@ Parser.numberParser = function(filename, content) {
|
|
|
304
304
|
return Number.isNaN(numberValue) ? undefined : numberValue;
|
|
305
305
|
};
|
|
306
306
|
|
|
307
|
-
var order = ['js', 'ts', 'json', 'json5', 'hjson', 'toml', 'coffee', 'iced', 'yaml', 'yml', 'cson', 'properties', 'xml',
|
|
307
|
+
var order = ['js', 'cjs', 'ts', 'json', 'json5', 'hjson', 'toml', 'coffee', 'iced', 'yaml', 'yml', 'cson', 'properties', 'xml',
|
|
308
308
|
'boolean', 'number'];
|
|
309
309
|
var definitions = {
|
|
310
|
+
cjs: Parser.jsParser,
|
|
310
311
|
coffee: Parser.coffeeParser,
|
|
311
312
|
cson: Parser.csonParser,
|
|
312
313
|
hjson: Parser.hjsonParser,
|