Initial commit
[yaffs-website] / node_modules / cosmiconfig / lib / readFile.js
1 'use strict';
2
3 var fs = require('fs');
4
5 module.exports = function (filepath, options) {
6   options = options || {};
7   options.throwNotFound = options.throwNotFound || false;
8
9   return new Promise(function (resolve, reject) {
10     fs.readFile(filepath, 'utf8', function (err, content) {
11       if (err && err.code === 'ENOENT' && !options.throwNotFound) {
12         return resolve(null);
13       }
14
15       if (err) return reject(err);
16
17       resolve(content);
18     });
19   });
20 };