4 const fs = require('fs');
10 function readFile(filepath , options ) {
11 options = options || {};
12 const throwNotFound = options.throwNotFound || false;
14 return new Promise((resolve, reject) => {
15 fs.readFile(filepath, 'utf8', (err, content) => {
16 if (err && err.code === 'ENOENT' && !throwNotFound) {
19 if (err) return reject(err);
25 readFile.sync = function readFileSync(
29 options = options || {};
30 const throwNotFound = options.throwNotFound || false;
33 return fs.readFileSync(filepath, 'utf8');
35 if (err.code === 'ENOENT' && !throwNotFound) {
42 module.exports = readFile;