mirror of
https://github.com/morhetz/gruvbox.git
synced 2025-11-16 23:33:38 -05:00
30 lines
850 B
JavaScript
30 lines
850 B
JavaScript
'use strict';
|
|
|
|
var path = require('path');
|
|
var fs = require('graceful-fs');
|
|
var Promise = require('pinkie-promise');
|
|
var parseJson = require('parse-json');
|
|
|
|
module.exports = function(packageDir, packageProp) {
|
|
var packagePath = path.join(packageDir, 'package.json');
|
|
return new Promise(function(resolve, reject) {
|
|
fs.readFile(packagePath, 'utf8', function(fileError, content) {
|
|
if (fileError) {
|
|
if (fileError.code === 'ENOENT') return resolve(null);
|
|
return reject(fileError);
|
|
}
|
|
resolve(content);
|
|
});
|
|
}).then(function(content) {
|
|
if (!content) return null;
|
|
var parsedContent = parseJson(content, packagePath);
|
|
var packagePropValue = parsedContent[packageProp];
|
|
if (!packagePropValue) return null;
|
|
|
|
return {
|
|
config: packagePropValue,
|
|
filepath: packagePath,
|
|
};
|
|
});
|
|
};
|