Initial commit
[yaffs-website] / node_modules / read-pkg-up / index.js
1 'use strict';
2 var findUp = require('find-up');
3 var readPkg = require('read-pkg');
4
5 module.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
20 module.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 };