Comparing version 0.3.6 to 0.4.0
{ | ||
"name": "app-conf", | ||
"version": "0.3.6", | ||
"version": "0.4.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -27,2 +27,3 @@ # app-conf [![Build Status](https://travis-ci.org/julien-f/nodejs-app-conf.png?branch=master)](https://travis-ci.org/julien-f/nodejs-app-conf) | ||
- [js-yaml](https://www.npmjs.org/package/js-yaml): to support YAML files; | ||
- [json5](https://www.npmjs.com/package/json5): to support advanced JSON files; | ||
- [strip-json-comments](https://www.npmjs.org/package/strip-json-comments): to support comments in JSON files. | ||
@@ -29,0 +30,0 @@ |
@@ -7,11 +7,18 @@ 'use strict' | ||
var stripJsonComments | ||
try { | ||
stripJsonComments = require('strip-json-comments') | ||
} catch (error) { | ||
stripJsonComments = function identity (val) { | ||
return val | ||
} | ||
} | ||
var formatJson = JSON.stringify | ||
var parseJson = (function () { | ||
try { | ||
return require('json5').parse | ||
} catch (_) {} | ||
try { | ||
var stripJsonComments = require('strip-json-comments') | ||
return function parseJson (json) { | ||
return JSON.parse(stripJsonComments(json)) | ||
} | ||
} catch (_) {} | ||
return JSON.parse | ||
})() | ||
var UnknownFormatError = require('./unknown-format-error') | ||
@@ -26,3 +33,3 @@ | ||
test: function (file) { | ||
return (file.path && /\.json$/i.test(file.path)) | ||
return (file.path && /\.json5?$/i.test(file.path)) | ||
}, | ||
@@ -32,3 +39,3 @@ | ||
unserialize: function (file) { | ||
return JSON.parse(stripJsonComments(String(file.content))) | ||
return parseJson(String(file.content)) | ||
}, | ||
@@ -41,3 +48,3 @@ | ||
return JSON.stringify(value, null, indent) | ||
return formatJson(value, null, indent) | ||
} | ||
@@ -44,0 +51,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10219
262
44