delay.js 748 B

12345678910111213141516171819202122232425
  1. var browserify = require('../');
  2. var vm = require('vm');
  3. var path = require('path');
  4. var test = require('tap').test;
  5. var through = require('through2');
  6. test('delay for pipelines', function (t) {
  7. t.plan(3);
  8. var b = browserify(__dirname + '/delay/main.js');
  9. b.pipeline.get('record').push(through.obj(function (row, enc, next) {
  10. if (row.file) {
  11. t.equal(row.file, path.join(__dirname, 'delay/main.js'));
  12. row.file = path.join(__dirname, 'delay/diverted.js');
  13. }
  14. this.push(row);
  15. next();
  16. }));
  17. b.bundle(function (err, src) {
  18. t.ifError(err);
  19. vm.runInNewContext(src, { console: { log: log } });
  20. function log (msg) { t.equal(msg, 900) }
  21. });
  22. });