tr_write.js 814 B

1234567891011121314151617181920212223242526272829303132
  1. var mdeps = require('../');
  2. var test = require('tap').test;
  3. var JSONStream = require('JSONStream');
  4. var packer = require('browser-pack');
  5. var path = require('path');
  6. var concat = require('concat-stream');
  7. test('transform write', function (t) {
  8. t.plan(1);
  9. var p = mdeps();
  10. p.write({
  11. transform: 'insert-www',
  12. options: {}
  13. });
  14. p.write({
  15. file: path.join(__dirname, 'tr_write/main.js'),
  16. id: path.join(__dirname, 'tr_write/main.js'),
  17. entry: true
  18. });
  19. p.end();
  20. var pack = packer();
  21. p.pipe(JSONStream.stringify()).pipe(pack);
  22. pack.pipe(concat(function (buf) {
  23. var src = buf.toString('utf8');
  24. Function('console', src)({ log: function (msg) {
  25. t.equal(msg, 'WORLD WIDE WOW');
  26. } });
  27. }));
  28. });