entry.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. var browserify = require('../');
  2. var vm = require('vm');
  3. var path = require('path');
  4. var test = require('tap').test;
  5. test('entry', function (t) {
  6. t.plan(3);
  7. var b = browserify(__dirname + '/entry/main.js');
  8. b.on('dep', function(row) {
  9. if (row.entry) t.equal(row.file, path.join(__dirname, 'entry/main.js'));
  10. });
  11. b.bundle(function (err, src) {
  12. var c = {
  13. done : function (one, two) {
  14. t.equal(one, 1);
  15. t.equal(two, 2);
  16. t.end();
  17. }
  18. };
  19. vm.runInNewContext(src, c);
  20. });
  21. });
  22. test('entry via add', function (t) {
  23. t.plan(3);
  24. var b = browserify();
  25. b.add(__dirname + '/entry/main.js');
  26. b.on('dep', function(row) {
  27. if (row.entry) t.equal(row.file, path.join(__dirname, 'entry/main.js'));
  28. });
  29. b.bundle(function (err, src) {
  30. var c = {
  31. done : function (one, two) {
  32. t.equal(one, 1);
  33. t.equal(two, 2);
  34. t.end();
  35. }
  36. };
  37. vm.runInNewContext(src, c);
  38. });
  39. });