You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.5 KiB

преди 4 години
  1. var path = require('path');
  2. var test = require('tape');
  3. var resolve = require('../');
  4. test('moduleDirectory strings', function (t) {
  5. t.plan(4);
  6. var dir = path.join(__dirname, 'module_dir');
  7. var xopts = {
  8. basedir: dir,
  9. moduleDirectory: 'xmodules'
  10. };
  11. resolve('aaa', xopts, function (err, res, pkg) {
  12. t.ifError(err);
  13. t.equal(res, path.join(dir, '/xmodules/aaa/index.js'));
  14. });
  15. var yopts = {
  16. basedir: dir,
  17. moduleDirectory: 'ymodules'
  18. };
  19. resolve('aaa', yopts, function (err, res, pkg) {
  20. t.ifError(err);
  21. t.equal(res, path.join(dir, '/ymodules/aaa/index.js'));
  22. });
  23. });
  24. test('moduleDirectory array', function (t) {
  25. t.plan(6);
  26. var dir = path.join(__dirname, 'module_dir');
  27. var aopts = {
  28. basedir: dir,
  29. moduleDirectory: ['xmodules', 'ymodules', 'zmodules']
  30. };
  31. resolve('aaa', aopts, function (err, res, pkg) {
  32. t.ifError(err);
  33. t.equal(res, path.join(dir, '/xmodules/aaa/index.js'));
  34. });
  35. var bopts = {
  36. basedir: dir,
  37. moduleDirectory: ['zmodules', 'ymodules', 'xmodules']
  38. };
  39. resolve('aaa', bopts, function (err, res, pkg) {
  40. t.ifError(err);
  41. t.equal(res, path.join(dir, '/ymodules/aaa/index.js'));
  42. });
  43. var copts = {
  44. basedir: dir,
  45. moduleDirectory: ['xmodules', 'ymodules', 'zmodules']
  46. };
  47. resolve('bbb', copts, function (err, res, pkg) {
  48. t.ifError(err);
  49. t.equal(res, path.join(dir, '/zmodules/bbb/main.js'));
  50. });
  51. });