1
0
mirror of https://github.com/thangisme/notes.git synced 2024-11-10 13:16:12 -05:00
notes/node_modules/cosmiconfig/lib/readFile.js
Patrick Marsceill b7b0d0d7bf
Initial commit
2017-03-09 13:16:08 -05:00

21 lines
468 B
JavaScript

'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);
});
});
};