index.js 383 B

123456789101112131415161718192021
  1. 'use strict';
  2. var fs = require('graceful-fs');
  3. module.exports = function fsReadFilePromise(filePath, options) {
  4. var resolve;
  5. var reject;
  6. fs.readFile(filePath, options, function(err, buf) {
  7. if (err) {
  8. reject(err);
  9. return;
  10. }
  11. resolve(buf);
  12. });
  13. return new Promise(function(_resolve, _reject) {
  14. resolve = _resolve;
  15. reject = _reject;
  16. });
  17. };