stream_file.js 874 B

1234567891011121314151617181920212223242526272829
  1. var browserify = require('../');
  2. var vm = require('vm');
  3. var test = require('tap').test;
  4. var fs = require('fs');
  5. var through = require('through2');
  6. var path = require('path');
  7. test('stream file', function (t) {
  8. var expected = {};
  9. expected[ path.join(__dirname, 'stream/fake.js') ] = true;
  10. expected[ path.join(__dirname, 'stream/bar.js' ) ] = true;
  11. expected[ path.join(__dirname, 'stream/foo.js' ) ] = true;
  12. t.plan(5);
  13. var stream = fs.createReadStream(__dirname + '/stream/main.js');
  14. stream.file = path.join(__dirname, '/stream/fake.js');
  15. var b = browserify(stream, { basedir: __dirname + '/stream' });
  16. b.transform(function (file) {
  17. t.ok(expected[file]);
  18. delete expected[file];
  19. return through();
  20. });
  21. b.bundle(function (err, src) {
  22. vm.runInNewContext(src, { t: t });
  23. });
  24. });