Skip to content

Commit d2eabf4

Browse files
committed
Remove undocumented passParsingErrors option
1 parent 782f185 commit d2eabf4

File tree

4 files changed

+3
-95
lines changed

4 files changed

+3
-95
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
- **BREAKING:** Remove global `spaces` option.
2+
- Remove undocumented `passParsingErrors` option.
23
- Added `EOL` override option to `writeFile` when using `spaces`. [#89]
34

45
3.0.1 / 2017-07-05

index.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ function readFile (file, options, callback) {
1919
var fs = options.fs || _fs
2020

2121
var shouldThrow = true
22-
// DO NOT USE 'passParsingErrors' THE NAME WILL CHANGE!!!, use 'throws' instead
23-
if ('passParsingErrors' in options) {
24-
shouldThrow = options.passParsingErrors
25-
} else if ('throws' in options) {
22+
if ('throws' in options) {
2623
shouldThrow = options.throws
2724
}
2825

@@ -56,10 +53,7 @@ function readFileSync (file, options) {
5653
var fs = options.fs || _fs
5754

5855
var shouldThrow = true
59-
// DO NOT USE 'passParsingErrors' THE NAME WILL CHANGE!!!, use 'throws' instead
60-
if ('passParsingErrors' in options) {
61-
shouldThrow = options.passParsingErrors
62-
} else if ('throws' in options) {
56+
if ('throws' in options) {
6357
shouldThrow = options.throws
6458
}
6559

test/read-file-sync.test.js

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,6 @@ describe('+ readFileSync()', function () {
5050
})
5151
})
5252

53-
describe('> when invalid JSON and passParsingErrors set to false', function () {
54-
it('should return null', function () {
55-
var file = path.join(TEST_DIR, 'somefile4-invalid.json')
56-
var data = '{not valid JSON'
57-
fs.writeFileSync(file, data)
58-
59-
assert.throws(function () {
60-
jf.readFileSync(file)
61-
})
62-
63-
var obj = jf.readFileSync(file, {passParsingErrors: false})
64-
assert.strictEqual(obj, null)
65-
})
66-
})
67-
6853
describe('> when invalid JSON and throws set to false', function () {
6954
it('should return null', function () {
7055
var file = path.join(TEST_DIR, 'somefile4-invalid.json')
@@ -80,22 +65,6 @@ describe('+ readFileSync()', function () {
8065
})
8166
})
8267

83-
describe('> when invalid JSON and passParsingErrors set to true', function () {
84-
it('should return null', function () {
85-
var file = path.join(TEST_DIR, 'somefile4-invalid.json')
86-
var data = '{not valid JSON'
87-
fs.writeFileSync(file, data)
88-
89-
assert.throws(function () {
90-
jf.readFileSync(file)
91-
})
92-
93-
assert.throws(function () {
94-
jf.readFileSync(file, {throws: true})
95-
})
96-
})
97-
})
98-
9968
describe('> when invalid JSON and throws set to true', function () {
10069
it('should throw an exception', function () {
10170
var file = path.join(TEST_DIR, 'somefile4-invalid.json')

test/read-file.test.js

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -75,62 +75,6 @@ describe('+ readFile()', function () {
7575
})
7676
})
7777

78-
describe('> when invalid JSON and throws set to false', function () {
79-
it('should return null and no error', function (done) {
80-
var fn = 'somefile4-invalid.json'
81-
var file = path.join(TEST_DIR, fn)
82-
var data = '{not valid JSON'
83-
var bothDone = false
84-
fs.writeFileSync(file, data)
85-
86-
jf.readFile(file, function (err, obj2) {
87-
assert(err instanceof Error)
88-
assert(err.message.match(fn))
89-
if (bothDone) {
90-
done()
91-
}
92-
bothDone = true
93-
})
94-
95-
jf.readFile(file, {throws: false}, function (err, obj2) {
96-
assert.ifError(err)
97-
assert.strictEqual(obj2, null)
98-
if (bothDone) {
99-
done()
100-
}
101-
bothDone = true
102-
})
103-
})
104-
})
105-
106-
describe('> when invalid JSON and throws set to true', function () {
107-
it('should return an error', function (done) {
108-
var fn = 'somefile4-invalid.json'
109-
var file = path.join(TEST_DIR, fn)
110-
var data = '{not valid JSON'
111-
var bothDone = false
112-
fs.writeFileSync(file, data)
113-
114-
jf.readFile(file, function (err, obj2) {
115-
assert(err instanceof Error)
116-
assert(err.message.match(fn))
117-
if (bothDone) {
118-
done()
119-
}
120-
bothDone = true
121-
})
122-
123-
jf.readFile(file, {throws: true}, function (err, obj2) {
124-
assert(err instanceof Error)
125-
assert(err.message.match(fn))
126-
if (bothDone) {
127-
done()
128-
}
129-
bothDone = true
130-
})
131-
})
132-
})
133-
13478
describe('> when invalid JSON and throws set to true', function () {
13579
it('should return an error', function (done) {
13680
var fn = 'somefile4-invalid.json'

0 commit comments

Comments
 (0)