1
0
mirror of https://github.com/thangisme/notes.git synced 2024-11-01 01:27:31 -04:00
notes/node_modules/cosmiconfig/lib/loadPackageProp.js
Patrick Marsceill b7b0d0d7bf
Initial commit
2017-03-09 13:16:08 -05:00

22 lines
570 B
JavaScript

'use strict';
var path = require('path');
var parseJson = require('parse-json');
var readFile = require('./readFile');
module.exports = function (packageDir, options) {
var packagePath = path.join(packageDir, 'package.json');
return readFile(packagePath).then(function (content) {
if (!content) return null;
var parsedContent = parseJson(content, packagePath);
var packagePropValue = parsedContent[options.packageProp];
if (!packagePropValue) return null;
return {
config: packagePropValue,
filepath: packagePath,
};
});
};