aboutsummaryrefslogtreecommitdiff
path: root/node_modules/cosmiconfig/lib/loadPackageProp.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/cosmiconfig/lib/loadPackageProp.js')
-rw-r--r--node_modules/cosmiconfig/lib/loadPackageProp.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/node_modules/cosmiconfig/lib/loadPackageProp.js b/node_modules/cosmiconfig/lib/loadPackageProp.js
new file mode 100644
index 0000000..01e759f
--- /dev/null
+++ b/node_modules/cosmiconfig/lib/loadPackageProp.js
@@ -0,0 +1,21 @@
+'use strict';
+
+var path = require('path');
+var readFile = require('./readFile');
+var parseJson = require('./parseJson');
+
+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,
+ };
+ });
+};