mirror of
https://github.com/thangisme/notes.git
synced 2024-11-01 01:27:31 -04:00
22 lines
570 B
JavaScript
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,
|
|
};
|
|
});
|
|
};
|