Skip to content

Commit 5bb0a79

Browse files
dudeofawesomesindresorhus
authored andcommittedNov 1, 2018
Upgrade read-pkg to v4 (#7)
1 parent ecb0795 commit 5bb0a79

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed
 

‎index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
const path = require('path');
23
const findUp = require('find-up');
34
const readPkg = require('read-pkg');
45

@@ -8,7 +9,8 @@ module.exports = options => {
89
return {};
910
}
1011

11-
return readPkg(fp, options).then(pkg => ({pkg, path: fp}));
12+
return readPkg(Object.assign({}, options, {cwd: path.dirname(fp)}))
13+
.then(pkg => ({pkg, path: fp}));
1214
});
1315
};
1416

@@ -20,7 +22,7 @@ module.exports.sync = options => {
2022
}
2123

2224
return {
23-
pkg: readPkg.sync(fp, options),
25+
pkg: readPkg.sync(Object.assign({}, options, {cwd: path.dirname(fp)})),
2426
path: fp
2527
};
2628
};

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
],
4949
"dependencies": {
5050
"find-up": "^3.0.0",
51-
"read-pkg": "^3.0.0"
51+
"read-pkg": "^4.0.1"
5252
},
5353
"devDependencies": {
5454
"ava": "*",

‎test.js

+8
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@ test('async', async t => {
99
const x = await m({cwd});
1010
t.is(x.pkg.name, 'read-pkg-up');
1111
t.is(x.path, pkgPath);
12+
13+
const y = await m({cwd: '/'});
14+
t.is(y.pkg, undefined);
15+
t.is(y.path, undefined);
1216
});
1317

1418
test('sync', t => {
1519
const x = m.sync({cwd});
1620
t.is(x.pkg.name, 'read-pkg-up');
1721
t.is(x.path, pkgPath);
22+
23+
const y = m.sync({cwd: '/'});
24+
t.is(y.pkg, undefined);
25+
t.is(y.path, undefined);
1826
});

0 commit comments

Comments
 (0)
Please sign in to comment.