config 3.3.1 → 3.3.6

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 CHANGED
@@ -1,3 +1,32 @@
1
+ 3.3.6 / 2021-03-08
2
+ ==================
3
+
4
+ * Added publishConfig element to package.json to prevent publishing to the wrong repository - @lorenwest
5
+
6
+ 3.3.5 / 2021-03-05
7
+ ==================
8
+
9
+ * FIX [#628](https://github.com/lorenwest/node-config/issues/628) Uncaught ReferenceError: node_env_var_name is not defined @prnake
10
+
11
+ 3.3.4 / 2021-02-26
12
+ ==================
13
+
14
+ * FIX #517 0 loadFileConfigs incorrectly adds to getConfigSources @NguyenMatthieu
15
+
16
+ 3.3.3 / 2020-11-26
17
+ ==================
18
+
19
+ * FIX #460 - Strict mode warning refer to appropriate env variable @iCodeOkay
20
+ * Use Buffer.alloc and Buffer.from instead of contrsuctor @Fcmam5
21
+ * Add support for experimental .cjs modules @lenkan
22
+
23
+
24
+ 3.3.2 / 2020-09-24
25
+ ==================
26
+
27
+ * Fixed issue with Buffers in config throwing error in util.makeImmutable (#608) - Michal Wadas
28
+ * Added boolean and numeric types to custom environment variables - Ankur Narkhede @ankurnarkhede
29
+
1
30
  3.3.1 / 2020-03-25
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://avatars2.githubusercontent.com/u/373538?v=4><a href="https://github.com/lorenwest">lorenwest</a></td>
138
- <td><img src=https://avatars1.githubusercontent.com/u/25829?v=4><a href="https://github.com/markstos">markstos</a></td>
139
- <td><img src=https://avatars1.githubusercontent.com/u/1083065?v=4><a href="https://github.com/iMoses">iMoses</a></td>
140
- <td><img src=https://avatars3.githubusercontent.com/u/447151?v=4><a href="https://github.com/elliotttf">elliotttf</a></td>
141
- <td><img src=https://avatars1.githubusercontent.com/u/8839447?v=4><a href="https://github.com/jfelege">jfelege</a></td>
142
- <td><img src=https://avatars0.githubusercontent.com/u/66902?v=4><a href="https://github.com/leachiM2k">leachiM2k</a></td>
143
- </tr><tr><td><img src=https://avatars1.githubusercontent.com/u/791137?v=4><a href="https://github.com/josx">josx</a></td>
144
- <td><img src=https://avatars2.githubusercontent.com/u/133277?v=4><a href="https://github.com/enyo">enyo</a></td>
145
- <td><img src=https://avatars1.githubusercontent.com/u/4307697?v=4><a href="https://github.com/leosuncin">leosuncin</a></td>
146
- <td><img src=https://avatars3.githubusercontent.com/u/1077378?v=4><a href="https://github.com/arthanzel">arthanzel</a></td>
147
- <td><img src=https://avatars2.githubusercontent.com/u/1656140?v=4><a href="https://github.com/eheikes">eheikes</a></td>
148
- <td><img src=https://avatars3.githubusercontent.com/u/138707?v=4><a href="https://github.com/th507">th507</a></td>
149
- </tr><tr><td><img src=https://avatars2.githubusercontent.com/u/506460?v=4><a href="https://github.com/Osterjour">Osterjour</a></td>
150
- <td><img src=https://avatars3.githubusercontent.com/u/1751645?v=4><a href="https://github.com/cunneen">cunneen</a></td>
151
- <td><img src=https://avatars0.githubusercontent.com/u/842998?v=4><a href="https://github.com/nsabovic">nsabovic</a></td>
152
- <td><img src=https://avatars0.githubusercontent.com/u/5138570?v=4><a href="https://github.com/BadgerBadgerBadgerBadger">BadgerBadgerBadgerBadger</a></td>
153
- <td><img src=https://avatars2.githubusercontent.com/u/2529835?v=4><a href="https://github.com/simon-scherzinger">simon-scherzinger</a></td>
154
- <td><img src=https://avatars3.githubusercontent.com/u/8650543?v=4><a href="https://github.com/leonardovillela">leonardovillela</a></td>
155
- </tr><tr><td><img src=https://avatars1.githubusercontent.com/u/175627?v=4><a href="https://github.com/axelhzf">axelhzf</a></td>
156
- <td><img src=https://avatars3.githubusercontent.com/u/7782055?v=4><a href="https://github.com/benkroeger">benkroeger</a></td>
157
- <td><img src=https://avatars3.githubusercontent.com/u/1872824?v=4><a href="https://github.com/fgheorghe">fgheorghe</a></td>
158
- <td><img src=https://avatars3.githubusercontent.com/u/1443067?v=4><a href="https://github.com/IvanVergiliev">IvanVergiliev</a></td>
159
- <td><img src=https://avatars0.githubusercontent.com/u/1736957?v=4><a href="https://github.com/jpwilliams">jpwilliams</a></td>
160
- <td><img src=https://avatars2.githubusercontent.com/u/1246875?v=4><a href="https://github.com/jaylynch">jaylynch</a></td>
161
- </tr><tr><td><img src=https://avatars1.githubusercontent.com/u/145742?v=4><a href="https://github.com/jberrisch">jberrisch</a></td>
162
- <td><img src=https://avatars1.githubusercontent.com/u/9355665?v=4><a href="https://github.com/kgoerlitz">kgoerlitz</a></td>
163
- <td><img src=https://avatars0.githubusercontent.com/u/8525267?v=4><a href="https://github.com/bertho-zero">bertho-zero</a></td>
164
- <td><img src=https://avatars3.githubusercontent.com/u/1918551?v=4><a href="https://github.com/nitzan-shaked">nitzan-shaked</a></td>
165
- <td><img src=https://avatars3.githubusercontent.com/u/3058150?v=4><a href="https://github.com/robertrossmann">robertrossmann</a></td>
166
- <td><img src=https://avatars2.githubusercontent.com/u/498929?v=4><a href="https://github.com/roncli">roncli</a></td>
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 (prop.hasOwnProperty(property) && prop[property] != null) {
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 = {},
@@ -369,6 +369,9 @@ util.makeHidden = function(object, property, value) {
369
369
  * @return object {object} - The original object is returned - for chaining.
370
370
  */
371
371
  util.makeImmutable = function(object, property, value) {
372
+ if (Buffer.isBuffer(object)) {
373
+ return object;
374
+ }
372
375
  var properties = null;
373
376
 
374
377
  // Backwards compatibility mode where property/value can be specified
@@ -444,6 +447,29 @@ util.getConfigSources = function() {
444
447
  return configSources.slice(0);
445
448
  };
446
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
+
447
473
  /**
448
474
  * Load the individual file configurations.
449
475
  *
@@ -484,7 +510,7 @@ util.getConfigSources = function() {
484
510
  *
485
511
  * <p>
486
512
  * (deployment) is the deployment type, found in the $NODE_ENV environment
487
- * variable (which can be overriden by using $NODE_CONFIG_ENV
513
+ * variable (which can be overridden by using $NODE_CONFIG_ENV
488
514
  * environment variable). Defaults to 'development'.
489
515
  * </p>
490
516
  *
@@ -496,25 +522,42 @@ util.getConfigSources = function() {
496
522
  * <p>
497
523
  * If the $NODE_APP_INSTANCE environment variable (or --NODE_APP_INSTANCE
498
524
  * command line parameter) is set, then files with this appendage will be loaded.
499
- * See the Multiple Application Instances section of the main documentaion page
525
+ * See the Multiple Application Instances section of the main documentation page
500
526
  * for more information.
501
527
  * </p>
502
528
  *
503
529
  * @protected
504
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
505
533
  * @return config {Object} The configuration object
506
534
  */
507
- util.loadFileConfigs = function(configDir) {
535
+ util.loadFileConfigs = function(configDir, options) {
508
536
 
509
537
  // Initialize
510
538
  var t = this,
511
539
  config = {};
512
540
 
513
- // Initialize parameters from command line, environment, or default
514
- NODE_ENV = util.initParam('NODE_ENV', 'development');
541
+ // Specify variables that can be used to define the environment
542
+ var node_env_var_names = ['NODE_CONFIG_ENV', 'NODE_ENV'];
515
543
 
516
- // Override, NODE_ENV if NODE_CONFIG_ENV is specified.
517
- NODE_ENV = util.initParam('NODE_CONFIG_ENV', NODE_ENV);
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
+ });
518
561
 
519
562
  // Split files name, for loading multiple files.
520
563
  NODE_ENV = NODE_ENV.split(',');
@@ -598,7 +641,7 @@ util.loadFileConfigs = function(configDir) {
598
641
 
599
642
  var locatedFiles = util.locateMatchingFiles(CONFIG_DIR, allowedFiles);
600
643
  locatedFiles.forEach(function(fullFilename) {
601
- var configObj = util.parseFile(fullFilename);
644
+ var configObj = util.parseFile(fullFilename, options);
602
645
  if (configObj) {
603
646
  util.extendDeep(config, configObj);
604
647
  }
@@ -615,10 +658,13 @@ util.loadFileConfigs = function(configDir) {
615
658
  console.error('The $NODE_CONFIG environment variable is malformed JSON');
616
659
  }
617
660
  util.extendDeep(config, envConfig);
618
- configSources.push({
619
- name: "$NODE_CONFIG",
620
- parsed: envConfig,
621
- });
661
+ var skipConfigSources = util.getOption(options,'skipConfigSources', false);
662
+ if (!skipConfigSources){
663
+ configSources.push({
664
+ name: "$NODE_CONFIG",
665
+ parsed: envConfig,
666
+ });
667
+ }
622
668
  }
623
669
 
624
670
  // Override configurations from the --NODE_CONFIG command line
@@ -630,10 +676,13 @@ util.loadFileConfigs = function(configDir) {
630
676
  console.error('The --NODE_CONFIG={json} command line argument is malformed JSON');
631
677
  }
632
678
  util.extendDeep(config, cmdLineConfig);
633
- configSources.push({
634
- name: "--NODE_CONFIG argument",
635
- parsed: cmdLineConfig,
636
- });
679
+ var skipConfigSources = util.getOption(options,'skipConfigSources', false);
680
+ if (!skipConfigSources){
681
+ configSources.push({
682
+ name: "--NODE_CONFIG argument",
683
+ parsed: cmdLineConfig,
684
+ });
685
+ }
637
686
  }
638
687
 
639
688
  // Place the mixed NODE_CONFIG into the environment
@@ -695,7 +744,7 @@ util.resolveDeferredConfigs = function (config) {
695
744
 
696
745
  // First step is to put the properties of interest in an array
697
746
  for (var property in prop) {
698
- if (prop.hasOwnProperty(property) && prop[property] != null) {
747
+ if (Object.hasOwnProperty.call(prop, property) && prop[property] != null) {
699
748
  propsToSort.push(property);
700
749
  }
701
750
  }
@@ -750,9 +799,10 @@ util.resolveDeferredConfigs = function (config) {
750
799
  * @protected
751
800
  * @method parseFile
752
801
  * @param fullFilename {string} The full file path and name
802
+ * @param options { object | undefined } parsing options. Current supported option: skipConfigSources: true|false
753
803
  * @return configObject {object|null} The configuration object parsed from the file
754
804
  */
755
- util.parseFile = function(fullFilename) {
805
+ util.parseFile = function(fullFilename, options) {
756
806
  var t = this, // Initialize
757
807
  configObject = null,
758
808
  fileContent = null,
@@ -794,8 +844,9 @@ util.parseFile = function(fullFilename) {
794
844
  throw new Error("Cannot parse config file: '" + fullFilename + "': " + e3);
795
845
  }
796
846
 
797
- // Keep track of this configuration sources, including empty ones
798
- if (typeof configObject === 'object') {
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) {
799
850
  configSources.push({
800
851
  name: fullFilename,
801
852
  original: fileContent,
@@ -807,7 +858,7 @@ util.parseFile = function(fullFilename) {
807
858
  };
808
859
 
809
860
  /**
810
- * Parse and return the specied string with the specified format.
861
+ * Parse and return the specified string with the specified format.
811
862
  *
812
863
  * The format determines the parser to use.
813
864
  *
@@ -949,7 +1000,7 @@ util.cloneDeep = function cloneDeep(parent, depth, circular, prototype) {
949
1000
  } else if (Utils.isDate(parent)) {
950
1001
  child = new Date(parent.getTime());
951
1002
  } else if (useBuffer && Buffer.isBuffer(parent)) {
952
- child = new Buffer(parent.length);
1003
+ child = Buffer.alloc(parent.length);
953
1004
  parent.copy(child);
954
1005
  return child;
955
1006
  } else {
@@ -1005,7 +1056,7 @@ util.setPath = function (object, path, value) {
1005
1056
  }
1006
1057
  else {
1007
1058
  nextKey = path.shift();
1008
- if (!object.hasOwnProperty(nextKey)) {
1059
+ if (!Object.hasOwnProperty.call(object, nextKey)) {
1009
1060
  object[nextKey] = {};
1010
1061
  }
1011
1062
  util.setPath(object[nextKey], path, value);
@@ -1020,9 +1071,9 @@ util.setPath = function (object, path, value) {
1020
1071
  *
1021
1072
  * @protected
1022
1073
  * @method substituteDeep
1023
- * @param substitionMap {object} - an object whose terminal (non-subobject) values are strings
1074
+ * @param substitutionMap {object} - an object whose terminal (non-subobject) values are strings
1024
1075
  * @param variables {object[string:value]} - usually process.env, a flat object used to transform
1025
- * terminal values in a copy of substititionMap.
1076
+ * terminal values in a copy of substitutionMap.
1026
1077
  * @returns {object} - deep copy of substitutionMap with only those paths whose terminal values
1027
1078
  * corresponded to a key in `variables`
1028
1079
  */
@@ -1067,7 +1118,7 @@ util.substituteDeep = function (substitutionMap, variables) {
1067
1118
  *
1068
1119
  * @protected
1069
1120
  * @method getCustomEnvVars
1070
- * @param CONFIG_DIR {string} - the passsed configuration directory
1121
+ * @param CONFIG_DIR {string} - the passed configuration directory
1071
1122
  * @param extNames {Array[string]} - acceptable configuration file extension names.
1072
1123
  * @returns {object} - mapped environment variables or {} if there are none
1073
1124
  */
@@ -1239,7 +1290,7 @@ util.extendDeep = function(mergeInto) {
1239
1290
  var fromIsDeferredFunc = mergeFrom[prop] instanceof DeferredConfig;
1240
1291
  var isDeferredFunc = mergeInto[prop] instanceof DeferredConfig;
1241
1292
 
1242
- if (fromIsDeferredFunc && mergeInto.hasOwnProperty(prop)) {
1293
+ if (fromIsDeferredFunc && Object.hasOwnProperty.call(mergeInto, prop)) {
1243
1294
  mergeFrom[prop]._original = isDeferredFunc ? mergeInto[prop]._original : mergeInto[prop];
1244
1295
  }
1245
1296
  // Extend recursively if both elements are objects and target is not really a deferred function
@@ -1406,15 +1457,15 @@ util.runStrictnessChecks = function (config) {
1406
1457
  });
1407
1458
  // development is special-cased because it's the default value
1408
1459
  if (env && (env !== 'development') && !anyFilesMatchEnv) {
1409
- _warnOrThrow("NODE_ENV value of '"+env+"' did not match any deployment config file names.");
1460
+ _warnOrThrow(NODE_ENV_VAR_NAME+" value of '"+env+"' did not match any deployment config file names.");
1410
1461
  }
1411
1462
  // Throw if NODE_ENV matches' default' or 'local'
1412
1463
  if ((env === 'default') || (env === 'local')) {
1413
- _warnOrThrow("NODE_ENV value of '"+env+"' is ambiguous.");
1464
+ _warnOrThrow(NODE_ENV_VAR_NAME+" value of '"+env+"' is ambiguous.");
1414
1465
  }
1415
1466
  });
1416
1467
 
1417
- // Throw an exception if there's no explict config file for NODE_APP_INSTANCE
1468
+ // Throw an exception if there's no explicit config file for NODE_APP_INSTANCE
1418
1469
  var anyFilesMatchInstance = sourceFilenames.some(function (filename) {
1419
1470
  return filename.match(APP_INSTANCE);
1420
1471
  });
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "config",
3
- "version": "3.3.1",
3
+ "version": "3.3.6",
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
7
  "homepage": "http://lorenwest.github.com/node-config",
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": ">= 6.0.0"
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
@@ -281,8 +281,33 @@ Parser.stripYamlComments = function(fileStr) {
281
281
  return fileStr.replace(/^\s*#.*/mg,'').replace(/^\s*[\n|\r]+/mg,'');
282
282
  };
283
283
 
284
- var order = ['js', 'ts', 'json', 'json5', 'hjson', 'toml', 'coffee', 'iced', 'yaml', 'yml', 'cson', 'properties', 'xml'];
284
+ /**
285
+ * Parses the environment variable to the boolean equivalent.
286
+ * Defaults to false
287
+ *
288
+ * @param {String} content - Environment variable value
289
+ * @return {boolean} - Boolean value fo the passed variable value
290
+ */
291
+ Parser.booleanParser = function(filename, content) {
292
+ return content === 'true';
293
+ };
294
+
295
+ /**
296
+ * Parses the environment variable to the number equivalent.
297
+ * Defaults to undefined
298
+ *
299
+ * @param {String} content - Environment variable value
300
+ * @return {Number} - Number value fo the passed variable value
301
+ */
302
+ Parser.numberParser = function(filename, content) {
303
+ const numberValue = Number(content);
304
+ return Number.isNaN(numberValue) ? undefined : numberValue;
305
+ };
306
+
307
+ var order = ['js', 'cjs', 'ts', 'json', 'json5', 'hjson', 'toml', 'coffee', 'iced', 'yaml', 'yml', 'cson', 'properties', 'xml',
308
+ 'boolean', 'number'];
285
309
  var definitions = {
310
+ cjs: Parser.jsParser,
286
311
  coffee: Parser.coffeeParser,
287
312
  cson: Parser.csonParser,
288
313
  hjson: Parser.hjsonParser,
@@ -296,6 +321,8 @@ var definitions = {
296
321
  xml: Parser.xmlParser,
297
322
  yaml: Parser.yamlParser,
298
323
  yml: Parser.yamlParser,
324
+ boolean: Parser.booleanParser,
325
+ number: Parser.numberParser
299
326
  };
300
327
 
301
328
  Parser.getParser = function(name) {
package/raw.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * This is meant to wrap configuration objects that should be left as is,
3
- * meaning that the object or its protoype will not be modified in any way
3
+ * meaning that the object or its prototype will not be modified in any way
4
4
  */
5
5
  function RawConfig () {
6
6
  }