2 const path = require('path');
3 const loadJsonFile = require('load-json-file');
4 const pathType = require('path-type');
6 module.exports = (fp, opts) => {
7 if (typeof fp !== 'string') {
14 return pathType.dir(fp)
17 fp = path.join(fp, 'package.json');
20 return loadJsonFile(fp);
23 if (opts.normalize !== false) {
24 require('normalize-package-data')(x);
31 module.exports.sync = (fp, opts) => {
32 if (typeof fp !== 'string') {
38 fp = pathType.dirSync(fp) ? path.join(fp, 'package.json') : fp;
40 const x = loadJsonFile.sync(fp);
42 if (opts.normalize !== false) {
43 require('normalize-package-data')(x);