paths.js 880 B

1234567891011121314151617181920212223242526272829303132
  1. var browserify = require('../');
  2. var vm = require('vm');
  3. var test = require('tap').test;
  4. test('$NODE_PATHS', function (t) {
  5. t.plan(3);
  6. var paths = [ __dirname + '/paths/x', __dirname + '/paths/y' ];
  7. var sep = /^win/i.test(process.platform) ? ';' : ':';
  8. process.env.NODE_PATH = (process.env.NODE_PATHS || '')
  9. .split(sep).concat(paths).join(sep)
  10. ;
  11. var b = browserify(__dirname + '/paths/main.js');
  12. b.bundle(function (err, src) {
  13. if (err) t.fail(err);
  14. vm.runInNewContext(src, { t: t });
  15. });
  16. });
  17. test('opts.paths', function (t) {
  18. t.plan(3);
  19. var b = browserify({
  20. paths: [ __dirname + '/paths/x', __dirname + '/paths/y' ],
  21. entries: __dirname + '/paths/main.js'
  22. });
  23. b.bundle(function (err, src) {
  24. if (err) t.fail(err);
  25. vm.runInNewContext(src, { t: t });
  26. });
  27. });