Comparing version 2.2.2 to 2.2.3
@@ -0,1 +1,5 @@ | ||
2.2.3 / 2015-10-14 | ||
------------------ | ||
- include file name in parse error. See: https://github.com/jprichardson/node-jsonfile/pull/34 | ||
2.2.2 / 2015-09-16 | ||
@@ -2,0 +6,0 @@ ------------------ |
15
index.js
@@ -16,2 +16,3 @@ var fs = require('fs') | ||
} catch (err2) { | ||
err2.message = file + ': ' + err2.message | ||
return callback(err2) | ||
@@ -31,9 +32,11 @@ } | ||
var shouldThrow = 'throws' in options ? options.throws : true | ||
var content = fs.readFileSync(file, options) | ||
if (shouldThrow) { // i.e. throw on invalid JSON | ||
return JSON.parse(fs.readFileSync(file, options), options.reviver) | ||
} else { | ||
try { | ||
return JSON.parse(fs.readFileSync(file, options), options.reviver) | ||
} catch (err) { | ||
try { | ||
return JSON.parse(content, options.reviver) | ||
} catch (err) { | ||
if (shouldThrow) { | ||
err.message = file + ': ' + err.message | ||
throw err | ||
} else { | ||
return null | ||
@@ -40,0 +43,0 @@ } |
{ | ||
"name": "jsonfile", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "Easily read/write JSON files.", | ||
@@ -5,0 +5,0 @@ "repository": { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9237
71
0