blob: beb3d483245413c069064659d3353582e6faa847 [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001'use strict';
2var findUp = require('find-up');
3var readPkg = require('read-pkg');
4
5module.exports = function (opts) {
6 return findUp('package.json', opts).then(function (fp) {
7 if (!fp) {
8 return {};
9 }
10
11 return readPkg(fp, opts).then(function (pkg) {
12 return {
13 pkg: pkg,
14 path: fp
15 };
16 });
17 });
18};
19
20module.exports.sync = function (opts) {
21 var fp = findUp.sync('package.json', opts);
22
23 if (!fp) {
24 return {};
25 }
26
27 return {
28 pkg: readPkg.sync(fp, opts),
29 path: fp
30 };
31};