From 26105034da4fcce7ac883c899d781f016559310d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 8 Nov 2018 00:38:48 +0800 Subject: switch to vuepress --- node_modules/cosmiconfig/dist/readFile.js | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 node_modules/cosmiconfig/dist/readFile.js (limited to 'node_modules/cosmiconfig/dist/readFile.js') diff --git a/node_modules/cosmiconfig/dist/readFile.js b/node_modules/cosmiconfig/dist/readFile.js new file mode 100644 index 00000000..4fd76cfe --- /dev/null +++ b/node_modules/cosmiconfig/dist/readFile.js @@ -0,0 +1,42 @@ +// +'use strict'; + +const fs = require('fs'); + + + + + +function readFile(filepath , options ) { + options = options || {}; + const throwNotFound = options.throwNotFound || false; + + return new Promise((resolve, reject) => { + fs.readFile(filepath, 'utf8', (err, content) => { + if (err && err.code === 'ENOENT' && !throwNotFound) { + return resolve(null); + } + if (err) return reject(err); + resolve(content); + }); + }); +} + +readFile.sync = function readFileSync( + filepath , + options +) { + options = options || {}; + const throwNotFound = options.throwNotFound || false; + + try { + return fs.readFileSync(filepath, 'utf8'); + } catch (err) { + if (err.code === 'ENOENT' && !throwNotFound) { + return null; + } + throw err; + } +}; + +module.exports = readFile; -- cgit v1.2.3