Skip to content

Commit

Permalink
Require Node.js 8 and drop pify (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyfarrell authored and sindresorhus committed Mar 10, 2019
1 parent efe7650 commit 7b3755c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ language: node_js
node_js:
- '10'
- '8'
- '6'
24 changes: 13 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
'use strict';
const fs = require('fs');
const pify = require('pify');
const {promisify} = require('util');

function type(fn, fn2, fp) {
async function type(fn, fn2, fp) {
if (typeof fp !== 'string') {
return Promise.reject(new TypeError(`Expected a string, got ${typeof fp}`));
throw new TypeError(`Expected a string, got ${typeof fp}`);
}

return pify(fs[fn])(fp)
.then(stats => stats[fn2]())
.catch(error => {
if (error.code === 'ENOENT') {
return false;
}
try {
const stats = await promisify(fs[fn])(fp);

throw error;
});
return stats[fn2]();
} catch (error) {
if (error.code === 'ENOENT') {
return false;
}

throw error;
}
}

function typeSync(fn, fn2, fp) {
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
"node": ">=8"
},
"scripts": {
"test": "xo && nyc ava"
Expand All @@ -35,9 +35,6 @@
"stats",
"filesystem"
],
"dependencies": {
"pify": "^4.0.1"
},
"devDependencies": {
"ava": "*",
"nyc": "^13.3.0",
Expand Down

0 comments on commit 7b3755c

Please sign in to comment.