config 3.3.1 → 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,9 @@
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
+
1
7
  3.3.1 / 2020-03-25
2
8
  ==================
3
9
 
package/lib/config.js CHANGED
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "config",
3
- "version": "3.3.1",
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>",
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) {