wrap.js 525 B

1234567891011121314
  1. const gutil = require('gulp-util');
  2. const through = require('through2');
  3. module.exports = function (options) {
  4. return through.obj(function (file, enc, cb) {
  5. if (file.isNull()) return cb();
  6. if (file.isStream()) return this.emit('error', new gutil.PluginError('VM-wrap', 'Stream is not supported.'));
  7. const header = options.header || '';
  8. const contents = String(file.contents);
  9. const footer = options.footer || '';
  10. file.contents = new Buffer(header + contents + footer);
  11. cb(null, file);
  12. });
  13. };