bufferFile.js 382 B

12345678910111213141516171819202122
  1. 'use strict';
  2. var fs = require('graceful-fs');
  3. var stripBom = require('strip-bom');
  4. function bufferFile(file, opt, cb) {
  5. fs.readFile(file.path, function(err, data) {
  6. if (err) {
  7. return cb(err);
  8. }
  9. if (opt.stripBOM) {
  10. file.contents = stripBom(data);
  11. } else {
  12. file.contents = data;
  13. }
  14. cb(null, file);
  15. });
  16. }
  17. module.exports = bufferFile;