Comparing version 2.1.1 to 2.1.2
@@ -0,1 +1,5 @@ | ||
2.1.2 / 2015-06-22 | ||
------------------ | ||
- fixed if passed `readFileSync(file, 'utf8')`. See: https://github.com/jprichardson/node-jsonfile/issues/25 | ||
2.1.1 / 2015-06-19 | ||
@@ -2,0 +6,0 @@ ------------------ |
@@ -25,2 +25,6 @@ var fs = require('fs') | ||
options = options || {} | ||
if (typeof options === 'string') { | ||
options = {encoding: options} | ||
} | ||
var shouldThrow = 'throws' in options ? options.throw : true | ||
@@ -27,0 +31,0 @@ |
{ | ||
"name": "jsonfile", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "Easily read/write JSON files.", | ||
@@ -5,0 +5,0 @@ "repository": { |
38
test.js
@@ -63,3 +63,3 @@ var assert = require('assert') | ||
describe('> when passing null and callback', function () { | ||
it('should not throw an error', function () { | ||
it('should not throw an error', function (done) { | ||
var file = path.join(TEST_DIR, 'somefile.json') | ||
@@ -75,5 +75,23 @@ | ||
assert.strictEqual(obj.name, 'jp') | ||
done() | ||
}) | ||
}) | ||
}) | ||
describe('> when passing encoding string as option', function () { | ||
it('should not throw an error', function (done) { | ||
var file = path.join(TEST_DIR, 'somefile.json') | ||
var obj = { | ||
name: 'jp' | ||
} | ||
fs.writeFileSync(file, JSON.stringify(obj)) | ||
jf.readFile(file, 'utf8', function (err) { | ||
assert.ifError(err) | ||
assert.strictEqual(obj.name, 'jp') | ||
done() | ||
}) | ||
}) | ||
}) | ||
}) | ||
@@ -131,2 +149,20 @@ | ||
}) | ||
describe('> when passing encoding string as option', function () { | ||
it('should not throw an error', function () { | ||
var file = path.join(TEST_DIR, 'somefile.json') | ||
var obj = { | ||
name: 'jp' | ||
} | ||
fs.writeFileSync(file, JSON.stringify(obj)) | ||
try { | ||
var data = jf.readFileSync(file, 'utf8') | ||
} catch (err) { | ||
assert.ifError(err) | ||
} | ||
assert.strictEqual(data.name, 'jp') | ||
}) | ||
}) | ||
}) | ||
@@ -133,0 +169,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
16330
311