aboutsummaryrefslogtreecommitdiff
path: root/node_modules/cosmiconfig/lib/readFile.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/cosmiconfig/lib/readFile.js')
-rw-r--r--node_modules/cosmiconfig/lib/readFile.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/node_modules/cosmiconfig/lib/readFile.js b/node_modules/cosmiconfig/lib/readFile.js
new file mode 100644
index 0000000..95e1e2e
--- /dev/null
+++ b/node_modules/cosmiconfig/lib/readFile.js
@@ -0,0 +1,20 @@
+'use strict';
+
+var fs = require('fs');
+
+module.exports = function (filepath, options) {
+ options = options || {};
+ options.throwNotFound = options.throwNotFound || false;
+
+ return new Promise(function (resolve, reject) {
+ fs.readFile(filepath, 'utf8', function (err, content) {
+ if (err && err.code === 'ENOENT' && !options.throwNotFound) {
+ return resolve(null);
+ }
+
+ if (err) return reject(err);
+
+ resolve(content);
+ });
+ });
+};