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