Skip to content

Commit be12a6b

Browse files
coreyfarrellsindresorhus
authored andcommitted
Require Node.js 8 and drop pify dependency (#19)
1 parent 008306c commit be12a6b

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ node_js:
33
- '12'
44
- '10'
55
- '8'
6-
- '6'

index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22
const path = require('path');
3+
const {promisify} = require('util');
34
const fs = require('graceful-fs');
45
const stripBom = require('strip-bom');
56
const parseJson = require('parse-json');
6-
const pify = require('pify');
77

88
const parse = (data, filePath, options = {}) => {
99
data = stripBom(data);
@@ -15,9 +15,6 @@ const parse = (data, filePath, options = {}) => {
1515
return parseJson(data, options.reviver, path.relative(process.cwd(), filePath));
1616
};
1717

18-
const loadJsonFile = (filePath, options) => pify(fs.readFile)(filePath, 'utf8').then(data => parse(data, filePath, options));
19-
18+
const loadJsonFile = async (filePath, options) => parse(await promisify(fs.readFile)(filePath, 'utf8'), filePath, options);
2019
module.exports = loadJsonFile;
21-
// TODO: Remove this for the next major release
22-
module.exports.default = loadJsonFile;
2320
module.exports.sync = (filePath, options) => parse(fs.readFileSync(filePath, 'utf8'), filePath, options);

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"url": "sindresorhus.com"
1111
},
1212
"engines": {
13-
"node": ">=6"
13+
"node": ">=8"
1414
},
1515
"scripts": {
1616
"test": "xo && ava && tsd"
@@ -31,9 +31,8 @@
3131
"dependencies": {
3232
"graceful-fs": "^4.1.15",
3333
"parse-json": "^4.0.0",
34-
"pify": "^4.0.1",
3534
"strip-bom": "^3.0.0",
36-
"type-fest": "^0.3.0"
35+
"type-fest": "^0.4.1"
3736
},
3837
"devDependencies": {
3938
"ava": "^1.4.1",

readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ $ npm install load-json-file
1717
```js
1818
const loadJsonFile = require('load-json-file');
1919

20-
loadJsonFile('foo.json').then(json => {
21-
console.log(json);
20+
(async () => {
21+
console.log(await loadJsonFile('foo.json'));
2222
//=> {foo: true}
23-
});
23+
})();
2424
```
2525

2626

0 commit comments

Comments
 (0)