tr_once.js 608 B

123456789101112131415161718192021
  1. var browserify = require('../');
  2. var vm = require('vm');
  3. var test = require('tap').test;
  4. var through = require('through2');
  5. var path = require('path');
  6. test('transform exactly once', function (t) {
  7. t.plan(3);
  8. var b = browserify(__dirname + '/tr_once/main.js', {
  9. transform: function (file) {
  10. t.equal(file, path.join(__dirname, 'tr_once/main.js') );
  11. return through();
  12. }
  13. });
  14. b.bundle(function (err, src) {
  15. t.ifError(err);
  16. vm.runInNewContext(src, { console: { log: log } });
  17. function log (msg) { t.equal(msg, 'wow') }
  18. });
  19. });