Skip to content

Commit 8aec334

Browse files
committed
Require Node.js 6
1 parent f824f80 commit 8aec334

10 files changed

+65
-71
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ charset = utf-8
77
trim_trailing_whitespace = true
88
insert_final_newline = true
99

10-
[{package.json,*.yml}]
10+
[*.yml]
1111
indent_style = space
1212
indent_size = 2

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
* text=auto
2+
*.js text eol=lf

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
yarn.lock

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
language: node_js
22
node_js:
3+
- '10'
4+
- '8'
35
- '6'
4-
- '4'

index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ const stripBom = require('strip-bom');
55
const parseJson = require('parse-json');
66
const pify = require('pify');
77

8-
const parse = (data, fp, options) => {
9-
options = options || {};
8+
const parse = (data, filePath, options = {}) => {
109
data = stripBom(data);
10+
1111
if (typeof options.beforeParse === 'function') {
1212
data = options.beforeParse(data);
1313
}
14-
return parseJson(data, options.reviver, path.relative('.', fp));
14+
15+
return parseJson(data, options.reviver, path.relative(process.cwd(), filePath));
1516
};
1617

17-
module.exports = (fp, options) => pify(fs.readFile)(fp, 'utf8').then(data => parse(data, fp, options));
18-
module.exports.sync = (fp, options) => parse(fs.readFileSync(fp, 'utf8'), fp, options);
18+
module.exports = (filePath, options) => pify(fs.readFile)(filePath, 'utf8').then(data => parse(data, filePath, options));
19+
module.exports.sync = (filePath, options) => parse(fs.readFileSync(filePath, 'utf8'), filePath, options);

license

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
The MIT License (MIT)
1+
MIT License
22

33
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
116

12-
The above copyright notice and this permission notice shall be included in
13-
all copies or substantial portions of the Software.
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
148

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

package.json

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,40 @@
11
{
2-
"name": "load-json-file",
3-
"version": "4.0.0",
4-
"description": "Read and parse a JSON file",
5-
"license": "MIT",
6-
"repository": "sindresorhus/load-json-file",
7-
"author": {
8-
"name": "Sindre Sorhus",
9-
"email": "[email protected]",
10-
"url": "sindresorhus.com"
11-
},
12-
"engines": {
13-
"node": ">=4"
14-
},
15-
"scripts": {
16-
"test": "xo && ava"
17-
},
18-
"files": [
19-
"index.js"
20-
],
21-
"keywords": [
22-
"read",
23-
"json",
24-
"parse",
25-
"file",
26-
"fs",
27-
"graceful",
28-
"load"
29-
],
30-
"dependencies": {
31-
"graceful-fs": "^4.1.2",
32-
"parse-json": "^4.0.0",
33-
"pify": "^3.0.0",
34-
"strip-bom": "^3.0.0"
35-
},
36-
"devDependencies": {
37-
"ava": "*",
38-
"xo": "*"
39-
},
40-
"xo": {
41-
"esnext": true
42-
}
2+
"name": "load-json-file",
3+
"version": "4.0.0",
4+
"description": "Read and parse a JSON file",
5+
"license": "MIT",
6+
"repository": "sindresorhus/load-json-file",
7+
"author": {
8+
"name": "Sindre Sorhus",
9+
"email": "[email protected]",
10+
"url": "sindresorhus.com"
11+
},
12+
"engines": {
13+
"node": ">=6"
14+
},
15+
"scripts": {
16+
"test": "xo && ava"
17+
},
18+
"files": [
19+
"index.js"
20+
],
21+
"keywords": [
22+
"read",
23+
"json",
24+
"parse",
25+
"file",
26+
"fs",
27+
"graceful",
28+
"load"
29+
],
30+
"dependencies": {
31+
"graceful-fs": "^4.1.2",
32+
"parse-json": "^4.0.0",
33+
"pify": "^3.0.0",
34+
"strip-bom": "^3.0.0"
35+
},
36+
"devDependencies": {
37+
"ava": "*",
38+
"xo": "*"
39+
}
4340
}

readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
## Install
99

1010
```
11-
$ npm install --save load-json-file
11+
$ npm install load-json-file
1212
```
1313

1414

@@ -26,7 +26,7 @@ loadJsonFile('foo.json').then(json => {
2626

2727
## API
2828

29-
### loadJsonFile(filepath, [options])
29+
### loadJsonFile(filePath, [options])
3030

3131
Returns a promise for the parsed JSON.
3232

@@ -48,7 +48,7 @@ Applies a function to the JSON string before parsing.
4848

4949
Type: `Function`
5050

51-
Prescribes how the value originally produced by parsing is transformed, before being returned. See [`JSON.parse` docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter) for more.
51+
Prescribes how the value originally produced by parsing is transformed, before being returned. See the [`JSON.parse` docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter) for more.
5252

5353

5454
## Related

test.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ test('sync', t => {
1313
t.is(m.sync(fixture).name, 'load-json-file');
1414
});
1515

16-
test('beforeParse', async t => {
17-
const data = await m(fixture, {beforeParse: s => s.replace('"name": "load-json-file"', '"name": "foo"')});
16+
test('beforeParse option', async t => {
17+
const data = await m(fixture, {
18+
beforeParse: string => string.replace('"name": "load-json-file"', '"name": "foo"')
19+
});
1820
t.is(data.name, 'foo');
1921
});
2022

21-
test('reviver', async t => {
22-
const data = await m(fixture, {reviver: (k, v) => k === 'name' ? 'foo' : v});
23+
test('reviver option', async t => {
24+
const data = await m(fixture, {
25+
reviver: (key, value) => key === 'name' ? 'foo' : value
26+
});
2327
t.is(data.name, 'foo');
2428
});

0 commit comments

Comments
 (0)