Skip to content

Commit 4412fe2

Browse files
committedMar 21, 2019
Require Node.js 8
1 parent 5bb0a79 commit 4412fe2

File tree

4 files changed

+31
-30
lines changed

4 files changed

+31
-30
lines changed
 

‎.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ language: node_js
22
node_js:
33
- '10'
44
- '8'
5-
- '6'

‎index.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,28 @@ const path = require('path');
33
const findUp = require('find-up');
44
const readPkg = require('read-pkg');
55

6-
module.exports = options => {
7-
return findUp('package.json', options).then(fp => {
8-
if (!fp) {
9-
return {};
10-
}
6+
module.exports = async options => {
7+
const filePath = await findUp('package.json', options);
118

12-
return readPkg(Object.assign({}, options, {cwd: path.dirname(fp)}))
13-
.then(pkg => ({pkg, path: fp}));
14-
});
9+
if (!filePath) {
10+
return {};
11+
}
12+
13+
return {
14+
pkg: await readPkg({...options, cwd: path.dirname(filePath)}),
15+
path: filePath
16+
};
1517
};
1618

1719
module.exports.sync = options => {
18-
const fp = findUp.sync('package.json', options);
20+
const filePath = findUp.sync('package.json', options);
1921

20-
if (!fp) {
22+
if (!filePath) {
2123
return {};
2224
}
2325

2426
return {
25-
pkg: readPkg.sync(Object.assign({}, options, {cwd: path.dirname(fp)})),
26-
path: fp
27+
pkg: readPkg.sync({...options, cwd: path.dirname(filePath)}),
28+
path: filePath
2729
};
2830
};

‎package.json

+4-4
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"
@@ -48,10 +48,10 @@
4848
],
4949
"dependencies": {
5050
"find-up": "^3.0.0",
51-
"read-pkg": "^4.0.1"
51+
"read-pkg": "^5.0.0"
5252
},
5353
"devDependencies": {
54-
"ava": "*",
55-
"xo": "*"
54+
"ava": "^1.3.1",
55+
"xo": "^0.24.0"
5656
}
5757
}

‎test.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import path from 'path';
22
import test from 'ava';
3-
import m from '.';
3+
import readPkgUp from '.';
44

55
const cwd = 'fixture';
66
const pkgPath = path.resolve('.', 'package.json');
77

88
test('async', async t => {
9-
const x = await m({cwd});
10-
t.is(x.pkg.name, 'read-pkg-up');
11-
t.is(x.path, pkgPath);
9+
const result = await readPkgUp({cwd});
10+
t.is(result.pkg.name, 'read-pkg-up');
11+
t.is(result.path, pkgPath);
1212

13-
const y = await m({cwd: '/'});
14-
t.is(y.pkg, undefined);
15-
t.is(y.path, undefined);
13+
const result2 = await readPkgUp({cwd: '/'});
14+
t.is(result2.pkg, undefined);
15+
t.is(result2.path, undefined);
1616
});
1717

1818
test('sync', t => {
19-
const x = m.sync({cwd});
20-
t.is(x.pkg.name, 'read-pkg-up');
21-
t.is(x.path, pkgPath);
19+
const result = readPkgUp.sync({cwd});
20+
t.is(result.pkg.name, 'read-pkg-up');
21+
t.is(result.path, pkgPath);
2222

23-
const y = m.sync({cwd: '/'});
24-
t.is(y.pkg, undefined);
25-
t.is(y.path, undefined);
23+
const result2 = readPkgUp.sync({cwd: '/'});
24+
t.is(result2.pkg, undefined);
25+
t.is(result2.path, undefined);
2626
});

0 commit comments

Comments
 (0)
Please sign in to comment.