config 3.2.5 → 3.3.2

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,24 @@
1
+ 3.3.2 / 2020-09-24
2
+ ==================
3
+
4
+ * Fixed issue with Buffers in config throwing error in util.makeImmutable (#608) - Michal Wadas
5
+ * Added boolean and numeric types to custom environment variables - Ankur Narkhede @ankurnarkhede
6
+
7
+ 3.3.1 / 2020-03-25
8
+ ==================
9
+
10
+ * Fix security vulnerability in json5 dependency - @twkel
11
+
12
+ 3.3.0 / 2020-02-26
13
+ ==================
14
+
15
+ * Allow all defined values in `substituteDeep` - @fostyfost
16
+
17
+ 3.2.6 / 2020-02-21
18
+ ==================
19
+
20
+ * Updated copyright date ranges
21
+
1
22
  3.2.5 / 2020-01-16
2
23
  ==================
3
24
 
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2010-2018, Loren West and other contributors
1
+ // Copyright 2010-2020, Loren West and other contributors
2
2
 
3
3
  // Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  // of this software and associated documentation files (the "Software"), to
package/README.md CHANGED
@@ -147,23 +147,23 @@ Contributors
147
147
  <td><img src=https://avatars2.githubusercontent.com/u/1656140?v=4><a href="https://github.com/eheikes">eheikes</a></td>
148
148
  <td><img src=https://avatars3.githubusercontent.com/u/138707?v=4><a href="https://github.com/th507">th507</a></td>
149
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>
150
151
  <td><img src=https://avatars0.githubusercontent.com/u/842998?v=4><a href="https://github.com/nsabovic">nsabovic</a></td>
151
152
  <td><img src=https://avatars0.githubusercontent.com/u/5138570?v=4><a href="https://github.com/BadgerBadgerBadgerBadger">BadgerBadgerBadgerBadger</a></td>
152
153
  <td><img src=https://avatars2.githubusercontent.com/u/2529835?v=4><a href="https://github.com/simon-scherzinger">simon-scherzinger</a></td>
153
154
  <td><img src=https://avatars3.githubusercontent.com/u/8650543?v=4><a href="https://github.com/leonardovillela">leonardovillela</a></td>
154
- <td><img src=https://avatars1.githubusercontent.com/u/175627?v=4><a href="https://github.com/axelhzf">axelhzf</a></td>
155
- </tr><tr><td><img src=https://avatars3.githubusercontent.com/u/7782055?v=4><a href="https://github.com/benkroeger">benkroeger</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>
156
157
  <td><img src=https://avatars3.githubusercontent.com/u/1872824?v=4><a href="https://github.com/fgheorghe">fgheorghe</a></td>
157
158
  <td><img src=https://avatars3.githubusercontent.com/u/1443067?v=4><a href="https://github.com/IvanVergiliev">IvanVergiliev</a></td>
158
159
  <td><img src=https://avatars0.githubusercontent.com/u/1736957?v=4><a href="https://github.com/jpwilliams">jpwilliams</a></td>
159
160
  <td><img src=https://avatars2.githubusercontent.com/u/1246875?v=4><a href="https://github.com/jaylynch">jaylynch</a></td>
160
- <td><img src=https://avatars1.githubusercontent.com/u/145742?v=4><a href="https://github.com/jberrisch">jberrisch</a></td>
161
- </tr><tr><td><img src=https://avatars1.githubusercontent.com/u/9355665?v=4><a href="https://github.com/kgoerlitz">kgoerlitz</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>
162
163
  <td><img src=https://avatars0.githubusercontent.com/u/8525267?v=4><a href="https://github.com/bertho-zero">bertho-zero</a></td>
163
164
  <td><img src=https://avatars3.githubusercontent.com/u/1918551?v=4><a href="https://github.com/nitzan-shaked">nitzan-shaked</a></td>
164
165
  <td><img src=https://avatars3.githubusercontent.com/u/3058150?v=4><a href="https://github.com/robertrossmann">robertrossmann</a></td>
165
166
  <td><img src=https://avatars2.githubusercontent.com/u/498929?v=4><a href="https://github.com/roncli">roncli</a></td>
166
- <td><img src=https://avatars2.githubusercontent.com/u/1355559?v=4><a href="https://github.com/superoven">superoven</a></td>
167
167
  </tr></table>
168
168
 
169
169
  License
@@ -171,6 +171,6 @@ License
171
171
 
172
172
  May be freely distributed under the [MIT license](https://raw.githubusercontent.com/lorenwest/node-config/master/LICENSE).
173
173
 
174
- Copyright (c) 2010-2018 Loren West
174
+ Copyright (c) 2010-2020 Loren West
175
175
  [and other contributors](https://github.com/lorenwest/node-config/graphs/contributors)
176
176
 
package/lib/config.js CHANGED
@@ -1,4 +1,4 @@
1
- // config.js (c) 2010-2015 Loren West and other contributors
1
+ // config.js (c) 2010-2020 Loren West and other contributors
2
2
  // May be freely distributed under the MIT license.
3
3
  // For further details and documentation:
4
4
  // http://lorenwest.github.com/node-config
@@ -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
@@ -1033,12 +1036,12 @@ util.substituteDeep = function (substitutionMap, variables) {
1033
1036
  for (var prop in map) {
1034
1037
  var value = map[prop];
1035
1038
  if (typeof(value) === 'string') { // We found a leaf variable name
1036
- if (vars[value]) { // if the vars provide a value set the value in the result map
1039
+ if (vars[value] !== undefined) { // if the vars provide a value set the value in the result map
1037
1040
  util.setPath(result, pathTo.concat(prop), vars[value]);
1038
1041
  }
1039
1042
  }
1040
1043
  else if (util.isObject(value)) { // work on the subtree, giving it a clone of the pathTo
1041
- if('__name' in value && '__format' in value && vars[value.__name]) {
1044
+ if ('__name' in value && '__format' in value && vars[value.__name] !== undefined) {
1042
1045
  try {
1043
1046
  var parsedValue = util.parseString(vars[value.__name], value.__format);
1044
1047
  } catch(err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "config",
3
- "version": "3.2.5",
3
+ "version": "3.3.2",
4
4
  "main": "./lib/config.js",
5
5
  "description": "Configuration control for production node deployments",
6
6
  "author": "Loren West <open_source@lorenwest.com>",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "json5": "^1.0.1"
22
+ "json5": "^2.1.1"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "^7.0.8",
package/parser.js CHANGED
@@ -281,7 +281,31 @@ 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', 'ts', 'json', 'json5', 'hjson', 'toml', 'coffee', 'iced', 'yaml', 'yml', 'cson', 'properties', 'xml',
308
+ 'boolean', 'number'];
285
309
  var definitions = {
286
310
  coffee: Parser.coffeeParser,
287
311
  cson: Parser.csonParser,
@@ -296,6 +320,8 @@ var definitions = {
296
320
  xml: Parser.xmlParser,
297
321
  yaml: Parser.yamlParser,
298
322
  yml: Parser.yamlParser,
323
+ boolean: Parser.booleanParser,
324
+ number: Parser.numberParser
299
325
  };
300
326
 
301
327
  Parser.getParser = function(name) {