entry_relative.js 1.1 KB

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