config 3.3.2 → 3.3.7
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 +29 -0
- package/README.md +30 -30
- package/async.js +1 -1
- package/lib/config.js +81 -33
- package/package.json +6 -3
- package/parser.js +7 -2
- package/raw.js +1 -1
package/History.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
3.3.7 / 2022-01-11
|
|
2
|
+
==================
|
|
3
|
+
|
|
4
|
+
* No new changes. 3.3.6 was not published to NPM in versioning mix-up.
|
|
5
|
+
* Release notes are moving to Github Releas page going forward.
|
|
6
|
+
|
|
7
|
+
3.3.6 / 2021-03-08
|
|
8
|
+
==================
|
|
9
|
+
|
|
10
|
+
* Added publishConfig element to package.json to prevent publishing to the wrong repository - @lorenwest
|
|
11
|
+
|
|
12
|
+
3.3.5 / 2021-03-05
|
|
13
|
+
==================
|
|
14
|
+
|
|
15
|
+
* FIX [#628](https://github.com/lorenwest/node-config/issues/628) Uncaught ReferenceError: node_env_var_name is not defined @prnake
|
|
16
|
+
|
|
17
|
+
3.3.4 / 2021-02-26
|
|
18
|
+
==================
|
|
19
|
+
|
|
20
|
+
* FIX #517 0 loadFileConfigs incorrectly adds to getConfigSources @NguyenMatthieu
|
|
21
|
+
|
|
22
|
+
3.3.3 / 2020-11-26
|
|
23
|
+
==================
|
|
24
|
+
|
|
25
|
+
* FIX #460 - Strict mode warning refer to appropriate env variable @iCodeOkay
|
|
26
|
+
* Use Buffer.alloc and Buffer.from instead of contrsuctor @Fcmam5
|
|
27
|
+
* Add support for experimental .cjs modules @lenkan
|
|
28
|
+
|
|
29
|
+
|
|
1
30
|
3.3.2 / 2020-09-24
|
|
2
31
|
==================
|
|
3
32
|
|
package/README.md
CHANGED
|
@@ -134,36 +134,36 @@ If you still don't see what you are looking for, here are some more resources to
|
|
|
134
134
|
|
|
135
135
|
Contributors
|
|
136
136
|
------------
|
|
137
|
-
<table id="contributors"><tr><td><img src=https://
|
|
138
|
-
<td><img src=https://
|
|
139
|
-
<td><img src=https://
|
|
140
|
-
<td><img src=https://
|
|
141
|
-
<td><img src=https://
|
|
142
|
-
<td><img src=https://
|
|
143
|
-
</tr><tr><td><img src=https://
|
|
144
|
-
<td><img src=https://
|
|
145
|
-
<td><img src=https://
|
|
146
|
-
<td><img src=https://
|
|
147
|
-
<td><img src=https://
|
|
148
|
-
<td><img src=https://
|
|
149
|
-
</tr><tr><td><img src=https://
|
|
150
|
-
<td><img src=https://
|
|
151
|
-
<td><img src=https://
|
|
152
|
-
<td><img src=https://
|
|
153
|
-
<td><img src=https://
|
|
154
|
-
<td><img src=https://
|
|
155
|
-
</tr><tr><td><img src=https://
|
|
156
|
-
<td><img src=https://
|
|
157
|
-
<td><img src=https://
|
|
158
|
-
<td><img src=https://
|
|
159
|
-
<td><img src=https://
|
|
160
|
-
<td><img src=https://
|
|
161
|
-
</tr><tr><td><img src=https://
|
|
162
|
-
<td><img src=https://
|
|
163
|
-
<td><img src=https://
|
|
164
|
-
<td><img src=https://
|
|
165
|
-
<td><img src=https://
|
|
166
|
-
<td><img src=https://
|
|
137
|
+
<table id="contributors"><tr><td><img src=https://avatars.githubusercontent.com/u/373538?v=4><a href="https://github.com/lorenwest">lorenwest</a></td>
|
|
138
|
+
<td><img src=https://avatars.githubusercontent.com/u/25829?v=4><a href="https://github.com/markstos">markstos</a></td>
|
|
139
|
+
<td><img src=https://avatars.githubusercontent.com/u/1083065?v=4><a href="https://github.com/iMoses">iMoses</a></td>
|
|
140
|
+
<td><img src=https://avatars.githubusercontent.com/u/447151?v=4><a href="https://github.com/elliotttf">elliotttf</a></td>
|
|
141
|
+
<td><img src=https://avatars.githubusercontent.com/u/8839447?v=4><a href="https://github.com/jfelege">jfelege</a></td>
|
|
142
|
+
<td><img src=https://avatars.githubusercontent.com/u/66902?v=4><a href="https://github.com/leachiM2k">leachiM2k</a></td>
|
|
143
|
+
</tr><tr><td><img src=https://avatars.githubusercontent.com/u/791137?v=4><a href="https://github.com/josx">josx</a></td>
|
|
144
|
+
<td><img src=https://avatars.githubusercontent.com/u/133277?v=4><a href="https://github.com/enyo">enyo</a></td>
|
|
145
|
+
<td><img src=https://avatars.githubusercontent.com/u/4307697?v=4><a href="https://github.com/leosuncin">leosuncin</a></td>
|
|
146
|
+
<td><img src=https://avatars.githubusercontent.com/u/1077378?v=4><a href="https://github.com/arthanzel">arthanzel</a></td>
|
|
147
|
+
<td><img src=https://avatars.githubusercontent.com/u/1656140?v=4><a href="https://github.com/eheikes">eheikes</a></td>
|
|
148
|
+
<td><img src=https://avatars.githubusercontent.com/u/138707?v=4><a href="https://github.com/th507">th507</a></td>
|
|
149
|
+
</tr><tr><td><img src=https://avatars.githubusercontent.com/u/506460?v=4><a href="https://github.com/Osterjour">Osterjour</a></td>
|
|
150
|
+
<td><img src=https://avatars.githubusercontent.com/u/1751645?v=4><a href="https://github.com/cunneen">cunneen</a></td>
|
|
151
|
+
<td><img src=https://avatars.githubusercontent.com/u/842998?v=4><a href="https://github.com/nsabovic">nsabovic</a></td>
|
|
152
|
+
<td><img src=https://avatars.githubusercontent.com/u/5138570?v=4><a href="https://github.com/BadgerBadgerBadgerBadger">BadgerBadgerBadgerBadger</a></td>
|
|
153
|
+
<td><img src=https://avatars.githubusercontent.com/u/2529835?v=4><a href="https://github.com/simon-scherzinger">simon-scherzinger</a></td>
|
|
154
|
+
<td><img src=https://avatars.githubusercontent.com/u/8650543?v=4><a href="https://github.com/leonardovillela">leonardovillela</a></td>
|
|
155
|
+
</tr><tr><td><img src=https://avatars.githubusercontent.com/u/175627?v=4><a href="https://github.com/axelhzf">axelhzf</a></td>
|
|
156
|
+
<td><img src=https://avatars.githubusercontent.com/u/7782055?v=4><a href="https://github.com/benkroeger">benkroeger</a></td>
|
|
157
|
+
<td><img src=https://avatars.githubusercontent.com/u/1872824?v=4><a href="https://github.com/fgheorghe">fgheorghe</a></td>
|
|
158
|
+
<td><img src=https://avatars.githubusercontent.com/u/1443067?v=4><a href="https://github.com/IvanVergiliev">IvanVergiliev</a></td>
|
|
159
|
+
<td><img src=https://avatars.githubusercontent.com/u/1736957?v=4><a href="https://github.com/jpwilliams">jpwilliams</a></td>
|
|
160
|
+
<td><img src=https://avatars.githubusercontent.com/u/1246875?v=4><a href="https://github.com/jaylynch">jaylynch</a></td>
|
|
161
|
+
</tr><tr><td><img src=https://avatars.githubusercontent.com/u/145742?v=4><a href="https://github.com/jberrisch">jberrisch</a></td>
|
|
162
|
+
<td><img src=https://avatars.githubusercontent.com/u/9355665?v=4><a href="https://github.com/kgoerlitz">kgoerlitz</a></td>
|
|
163
|
+
<td><img src=https://avatars.githubusercontent.com/u/8525267?v=4><a href="https://github.com/bertho-zero">bertho-zero</a></td>
|
|
164
|
+
<td><img src=https://avatars.githubusercontent.com/u/6686044?v=4><a href="https://github.com/NguyenMatthieu">NguyenMatthieu</a></td>
|
|
165
|
+
<td><img src=https://avatars.githubusercontent.com/u/1918551?v=4><a href="https://github.com/nitzan-shaked">nitzan-shaked</a></td>
|
|
166
|
+
<td><img src=https://avatars.githubusercontent.com/u/3058150?v=4><a href="https://github.com/robertrossmann">robertrossmann</a></td>
|
|
167
167
|
</tr></table>
|
|
168
168
|
|
|
169
169
|
License
|
package/async.js
CHANGED
|
@@ -43,7 +43,7 @@ function resolveAsyncConfigs(config) {
|
|
|
43
43
|
(function iterate(prop) {
|
|
44
44
|
var propsToSort = [];
|
|
45
45
|
for (var property in prop) {
|
|
46
|
-
if (
|
|
46
|
+
if (Object.hasOwnProperty.call(prop, property) && prop[property] != null) {
|
|
47
47
|
propsToSort.push(property);
|
|
48
48
|
}
|
|
49
49
|
}
|
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 = {},
|
|
@@ -447,6 +447,29 @@ util.getConfigSources = function() {
|
|
|
447
447
|
return configSources.slice(0);
|
|
448
448
|
};
|
|
449
449
|
|
|
450
|
+
/**
|
|
451
|
+
* Looks into an options object for a specific attribute
|
|
452
|
+
*
|
|
453
|
+
* <p>
|
|
454
|
+
* This method looks into the options object, and if an attribute is defined, returns it,
|
|
455
|
+
* and if not, returns the default value
|
|
456
|
+
* </p>
|
|
457
|
+
*
|
|
458
|
+
* @method getOption
|
|
459
|
+
* @param options {Object | undefined} the options object
|
|
460
|
+
* @param optionName {string} the attribute name to look for
|
|
461
|
+
* @param defaultValue { any } the default in case the options object is empty, or the attribute does not exist.
|
|
462
|
+
* @return options[optionName] if defined, defaultValue if not.
|
|
463
|
+
*/
|
|
464
|
+
util.getOption = function(options, optionName, defaultValue) {
|
|
465
|
+
if (options !== undefined && options[optionName] !== undefined){
|
|
466
|
+
return options[optionName];
|
|
467
|
+
} else {
|
|
468
|
+
return defaultValue;
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
|
|
450
473
|
/**
|
|
451
474
|
* Load the individual file configurations.
|
|
452
475
|
*
|
|
@@ -487,7 +510,7 @@ util.getConfigSources = function() {
|
|
|
487
510
|
*
|
|
488
511
|
* <p>
|
|
489
512
|
* (deployment) is the deployment type, found in the $NODE_ENV environment
|
|
490
|
-
* variable (which can be
|
|
513
|
+
* variable (which can be overridden by using $NODE_CONFIG_ENV
|
|
491
514
|
* environment variable). Defaults to 'development'.
|
|
492
515
|
* </p>
|
|
493
516
|
*
|
|
@@ -499,25 +522,42 @@ util.getConfigSources = function() {
|
|
|
499
522
|
* <p>
|
|
500
523
|
* If the $NODE_APP_INSTANCE environment variable (or --NODE_APP_INSTANCE
|
|
501
524
|
* command line parameter) is set, then files with this appendage will be loaded.
|
|
502
|
-
* See the Multiple Application Instances section of the main
|
|
525
|
+
* See the Multiple Application Instances section of the main documentation page
|
|
503
526
|
* for more information.
|
|
504
527
|
* </p>
|
|
505
528
|
*
|
|
506
529
|
* @protected
|
|
507
530
|
* @method loadFileConfigs
|
|
531
|
+
* @param configDir { string | null } the path to the directory containing the configurations to load
|
|
532
|
+
* @param options { object | undefined } parsing options. Current supported option: skipConfigSources: true|false
|
|
508
533
|
* @return config {Object} The configuration object
|
|
509
534
|
*/
|
|
510
|
-
util.loadFileConfigs = function(configDir) {
|
|
535
|
+
util.loadFileConfigs = function(configDir, options) {
|
|
511
536
|
|
|
512
537
|
// Initialize
|
|
513
538
|
var t = this,
|
|
514
539
|
config = {};
|
|
515
540
|
|
|
516
|
-
//
|
|
517
|
-
|
|
541
|
+
// Specify variables that can be used to define the environment
|
|
542
|
+
var node_env_var_names = ['NODE_CONFIG_ENV', 'NODE_ENV'];
|
|
518
543
|
|
|
519
|
-
//
|
|
520
|
-
|
|
544
|
+
// Loop through the variables to try and set environment
|
|
545
|
+
for (const node_env_var_name of node_env_var_names) {
|
|
546
|
+
NODE_ENV = util.initParam(node_env_var_name);
|
|
547
|
+
if (!!NODE_ENV) {
|
|
548
|
+
NODE_ENV_VAR_NAME = node_env_var_name;
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// If we haven't successfully set the environment using the variables, we'll default it
|
|
554
|
+
if (!NODE_ENV) {
|
|
555
|
+
NODE_ENV = 'development';
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
node_env_var_names.forEach(node_env_var_name => {
|
|
559
|
+
env[node_env_var_name] = NODE_ENV;
|
|
560
|
+
});
|
|
521
561
|
|
|
522
562
|
// Split files name, for loading multiple files.
|
|
523
563
|
NODE_ENV = NODE_ENV.split(',');
|
|
@@ -601,7 +641,7 @@ util.loadFileConfigs = function(configDir) {
|
|
|
601
641
|
|
|
602
642
|
var locatedFiles = util.locateMatchingFiles(CONFIG_DIR, allowedFiles);
|
|
603
643
|
locatedFiles.forEach(function(fullFilename) {
|
|
604
|
-
var configObj = util.parseFile(fullFilename);
|
|
644
|
+
var configObj = util.parseFile(fullFilename, options);
|
|
605
645
|
if (configObj) {
|
|
606
646
|
util.extendDeep(config, configObj);
|
|
607
647
|
}
|
|
@@ -618,10 +658,13 @@ util.loadFileConfigs = function(configDir) {
|
|
|
618
658
|
console.error('The $NODE_CONFIG environment variable is malformed JSON');
|
|
619
659
|
}
|
|
620
660
|
util.extendDeep(config, envConfig);
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
661
|
+
var skipConfigSources = util.getOption(options,'skipConfigSources', false);
|
|
662
|
+
if (!skipConfigSources){
|
|
663
|
+
configSources.push({
|
|
664
|
+
name: "$NODE_CONFIG",
|
|
665
|
+
parsed: envConfig,
|
|
666
|
+
});
|
|
667
|
+
}
|
|
625
668
|
}
|
|
626
669
|
|
|
627
670
|
// Override configurations from the --NODE_CONFIG command line
|
|
@@ -633,10 +676,13 @@ util.loadFileConfigs = function(configDir) {
|
|
|
633
676
|
console.error('The --NODE_CONFIG={json} command line argument is malformed JSON');
|
|
634
677
|
}
|
|
635
678
|
util.extendDeep(config, cmdLineConfig);
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
679
|
+
var skipConfigSources = util.getOption(options,'skipConfigSources', false);
|
|
680
|
+
if (!skipConfigSources){
|
|
681
|
+
configSources.push({
|
|
682
|
+
name: "--NODE_CONFIG argument",
|
|
683
|
+
parsed: cmdLineConfig,
|
|
684
|
+
});
|
|
685
|
+
}
|
|
640
686
|
}
|
|
641
687
|
|
|
642
688
|
// Place the mixed NODE_CONFIG into the environment
|
|
@@ -698,7 +744,7 @@ util.resolveDeferredConfigs = function (config) {
|
|
|
698
744
|
|
|
699
745
|
// First step is to put the properties of interest in an array
|
|
700
746
|
for (var property in prop) {
|
|
701
|
-
if (
|
|
747
|
+
if (Object.hasOwnProperty.call(prop, property) && prop[property] != null) {
|
|
702
748
|
propsToSort.push(property);
|
|
703
749
|
}
|
|
704
750
|
}
|
|
@@ -753,9 +799,10 @@ util.resolveDeferredConfigs = function (config) {
|
|
|
753
799
|
* @protected
|
|
754
800
|
* @method parseFile
|
|
755
801
|
* @param fullFilename {string} The full file path and name
|
|
802
|
+
* @param options { object | undefined } parsing options. Current supported option: skipConfigSources: true|false
|
|
756
803
|
* @return configObject {object|null} The configuration object parsed from the file
|
|
757
804
|
*/
|
|
758
|
-
util.parseFile = function(fullFilename) {
|
|
805
|
+
util.parseFile = function(fullFilename, options) {
|
|
759
806
|
var t = this, // Initialize
|
|
760
807
|
configObject = null,
|
|
761
808
|
fileContent = null,
|
|
@@ -797,8 +844,9 @@ util.parseFile = function(fullFilename) {
|
|
|
797
844
|
throw new Error("Cannot parse config file: '" + fullFilename + "': " + e3);
|
|
798
845
|
}
|
|
799
846
|
|
|
800
|
-
// Keep track of this configuration sources, including empty ones
|
|
801
|
-
|
|
847
|
+
// Keep track of this configuration sources, including empty ones, unless the skipConfigSources flag is set to true in the options
|
|
848
|
+
var skipConfigSources = util.getOption(options,'skipConfigSources', false);
|
|
849
|
+
if (typeof configObject === 'object' && !skipConfigSources) {
|
|
802
850
|
configSources.push({
|
|
803
851
|
name: fullFilename,
|
|
804
852
|
original: fileContent,
|
|
@@ -810,7 +858,7 @@ util.parseFile = function(fullFilename) {
|
|
|
810
858
|
};
|
|
811
859
|
|
|
812
860
|
/**
|
|
813
|
-
* Parse and return the
|
|
861
|
+
* Parse and return the specified string with the specified format.
|
|
814
862
|
*
|
|
815
863
|
* The format determines the parser to use.
|
|
816
864
|
*
|
|
@@ -952,7 +1000,7 @@ util.cloneDeep = function cloneDeep(parent, depth, circular, prototype) {
|
|
|
952
1000
|
} else if (Utils.isDate(parent)) {
|
|
953
1001
|
child = new Date(parent.getTime());
|
|
954
1002
|
} else if (useBuffer && Buffer.isBuffer(parent)) {
|
|
955
|
-
child =
|
|
1003
|
+
child = Buffer.alloc(parent.length);
|
|
956
1004
|
parent.copy(child);
|
|
957
1005
|
return child;
|
|
958
1006
|
} else {
|
|
@@ -1008,7 +1056,7 @@ util.setPath = function (object, path, value) {
|
|
|
1008
1056
|
}
|
|
1009
1057
|
else {
|
|
1010
1058
|
nextKey = path.shift();
|
|
1011
|
-
if (!
|
|
1059
|
+
if (!Object.hasOwnProperty.call(object, nextKey)) {
|
|
1012
1060
|
object[nextKey] = {};
|
|
1013
1061
|
}
|
|
1014
1062
|
util.setPath(object[nextKey], path, value);
|
|
@@ -1023,9 +1071,9 @@ util.setPath = function (object, path, value) {
|
|
|
1023
1071
|
*
|
|
1024
1072
|
* @protected
|
|
1025
1073
|
* @method substituteDeep
|
|
1026
|
-
* @param
|
|
1074
|
+
* @param substitutionMap {object} - an object whose terminal (non-subobject) values are strings
|
|
1027
1075
|
* @param variables {object[string:value]} - usually process.env, a flat object used to transform
|
|
1028
|
-
* terminal values in a copy of
|
|
1076
|
+
* terminal values in a copy of substitutionMap.
|
|
1029
1077
|
* @returns {object} - deep copy of substitutionMap with only those paths whose terminal values
|
|
1030
1078
|
* corresponded to a key in `variables`
|
|
1031
1079
|
*/
|
|
@@ -1036,12 +1084,12 @@ util.substituteDeep = function (substitutionMap, variables) {
|
|
|
1036
1084
|
for (var prop in map) {
|
|
1037
1085
|
var value = map[prop];
|
|
1038
1086
|
if (typeof(value) === 'string') { // We found a leaf variable name
|
|
1039
|
-
if (vars[value] !== undefined) { // if the vars provide a value set the value in the result map
|
|
1087
|
+
if (vars[value] !== undefined && vars[value] !== '') { // if the vars provide a value set the value in the result map
|
|
1040
1088
|
util.setPath(result, pathTo.concat(prop), vars[value]);
|
|
1041
1089
|
}
|
|
1042
1090
|
}
|
|
1043
1091
|
else if (util.isObject(value)) { // work on the subtree, giving it a clone of the pathTo
|
|
1044
|
-
if ('__name' in value && '__format' in value && vars[value.__name] !== undefined) {
|
|
1092
|
+
if ('__name' in value && '__format' in value && vars[value.__name] !== undefined && vars[value.__name] !== '') {
|
|
1045
1093
|
try {
|
|
1046
1094
|
var parsedValue = util.parseString(vars[value.__name], value.__format);
|
|
1047
1095
|
} catch(err) {
|
|
@@ -1070,7 +1118,7 @@ util.substituteDeep = function (substitutionMap, variables) {
|
|
|
1070
1118
|
*
|
|
1071
1119
|
* @protected
|
|
1072
1120
|
* @method getCustomEnvVars
|
|
1073
|
-
* @param CONFIG_DIR {string} - the
|
|
1121
|
+
* @param CONFIG_DIR {string} - the passed configuration directory
|
|
1074
1122
|
* @param extNames {Array[string]} - acceptable configuration file extension names.
|
|
1075
1123
|
* @returns {object} - mapped environment variables or {} if there are none
|
|
1076
1124
|
*/
|
|
@@ -1242,7 +1290,7 @@ util.extendDeep = function(mergeInto) {
|
|
|
1242
1290
|
var fromIsDeferredFunc = mergeFrom[prop] instanceof DeferredConfig;
|
|
1243
1291
|
var isDeferredFunc = mergeInto[prop] instanceof DeferredConfig;
|
|
1244
1292
|
|
|
1245
|
-
if (fromIsDeferredFunc &&
|
|
1293
|
+
if (fromIsDeferredFunc && Object.hasOwnProperty.call(mergeInto, prop)) {
|
|
1246
1294
|
mergeFrom[prop]._original = isDeferredFunc ? mergeInto[prop]._original : mergeInto[prop];
|
|
1247
1295
|
}
|
|
1248
1296
|
// Extend recursively if both elements are objects and target is not really a deferred function
|
|
@@ -1409,15 +1457,15 @@ util.runStrictnessChecks = function (config) {
|
|
|
1409
1457
|
});
|
|
1410
1458
|
// development is special-cased because it's the default value
|
|
1411
1459
|
if (env && (env !== 'development') && !anyFilesMatchEnv) {
|
|
1412
|
-
_warnOrThrow("
|
|
1460
|
+
_warnOrThrow(NODE_ENV_VAR_NAME+" value of '"+env+"' did not match any deployment config file names.");
|
|
1413
1461
|
}
|
|
1414
1462
|
// Throw if NODE_ENV matches' default' or 'local'
|
|
1415
1463
|
if ((env === 'default') || (env === 'local')) {
|
|
1416
|
-
_warnOrThrow("
|
|
1464
|
+
_warnOrThrow(NODE_ENV_VAR_NAME+" value of '"+env+"' is ambiguous.");
|
|
1417
1465
|
}
|
|
1418
1466
|
});
|
|
1419
1467
|
|
|
1420
|
-
// Throw an exception if there's no
|
|
1468
|
+
// Throw an exception if there's no explicit config file for NODE_APP_INSTANCE
|
|
1421
1469
|
var anyFilesMatchInstance = sourceFilenames.some(function (filename) {
|
|
1422
1470
|
return filename.match(APP_INSTANCE);
|
|
1423
1471
|
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "config",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.7",
|
|
4
4
|
"main": "./lib/config.js",
|
|
5
5
|
"description": "Configuration control for production node deployments",
|
|
6
6
|
"author": "Loren West <open_source@lorenwest.com>",
|
|
7
|
-
"homepage": "http://
|
|
7
|
+
"homepage": "http://github.com/lorenwest/node-config.git",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"registry": "https://registry.npmjs.org/"
|
|
10
|
+
},
|
|
8
11
|
"keywords": [
|
|
9
12
|
"conf",
|
|
10
13
|
"config",
|
|
@@ -41,7 +44,7 @@
|
|
|
41
44
|
"url": "http://github.com/lorenwest/node-config.git"
|
|
42
45
|
},
|
|
43
46
|
"engines": {
|
|
44
|
-
"node": ">=
|
|
47
|
+
"node": ">= 10.0.0"
|
|
45
48
|
},
|
|
46
49
|
"scripts": {
|
|
47
50
|
"test": "./node_modules/vows/bin/vows test/*.js --spec"
|
package/parser.js
CHANGED
|
@@ -55,6 +55,7 @@ Parser.tsParser = function(filename, content) {
|
|
|
55
55
|
if (!require.extensions['.ts']) {
|
|
56
56
|
require(TS_DEP).register({
|
|
57
57
|
lazy: true,
|
|
58
|
+
transpileOnly: true,
|
|
58
59
|
compilerOptions: {
|
|
59
60
|
allowJs: true,
|
|
60
61
|
}
|
|
@@ -136,7 +137,10 @@ Parser.yamlParser = function(filename, content) {
|
|
|
136
137
|
// The yaml library doesn't like strings that have newlines but don't
|
|
137
138
|
// end in a newline: https://github.com/visionmedia/js-yaml/issues/issue/13
|
|
138
139
|
content += '\n';
|
|
139
|
-
|
|
140
|
+
if (typeof VisionmediaYaml.eval === 'function') {
|
|
141
|
+
return VisionmediaYaml.eval(Parser.stripYamlComments(content));
|
|
142
|
+
}
|
|
143
|
+
return VisionmediaYaml.parse(Parser.stripYamlComments(content));
|
|
140
144
|
}
|
|
141
145
|
else {
|
|
142
146
|
console.error('No YAML parser loaded. Suggest adding js-yaml dependency to your package.json file.')
|
|
@@ -304,9 +308,10 @@ Parser.numberParser = function(filename, content) {
|
|
|
304
308
|
return Number.isNaN(numberValue) ? undefined : numberValue;
|
|
305
309
|
};
|
|
306
310
|
|
|
307
|
-
var order = ['js', 'ts', 'json', 'json5', 'hjson', 'toml', 'coffee', 'iced', 'yaml', 'yml', 'cson', 'properties', 'xml',
|
|
311
|
+
var order = ['js', 'cjs', 'ts', 'json', 'json5', 'hjson', 'toml', 'coffee', 'iced', 'yaml', 'yml', 'cson', 'properties', 'xml',
|
|
308
312
|
'boolean', 'number'];
|
|
309
313
|
var definitions = {
|
|
314
|
+
cjs: Parser.jsParser,
|
|
310
315
|
coffee: Parser.coffeeParser,
|
|
311
316
|
cson: Parser.csonParser,
|
|
312
317
|
hjson: Parser.hjsonParser,
|
package/raw.js
CHANGED