Skip to content

Commit a0df4a5

Browse files
author
Kelly Selden
committed
support opts.package in non-relative lookups
1 parent 1de53b2 commit a0df4a5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/async.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,12 @@ module.exports = function resolve(x, options, callback) {
183183
var dir = dirs[0];
184184

185185
var file = path.join(dir, x);
186-
loadAsFile(file, undefined, onfile);
186+
loadAsFile(file, opts.package, onfile);
187187

188188
function onfile(err, m, pkg) {
189189
if (err) return cb(err);
190190
if (m) return cb(null, m, pkg);
191-
loadAsDirectory(path.join(dir, x), undefined, ondir);
191+
loadAsDirectory(path.join(dir, x), opts.package, ondir);
192192
}
193193

194194
function ondir(err, n, pkg) {

test/resolver.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ test('bar', function (t) {
5555
resolve('foo', { basedir: dir + '/bar', 'package': { main: 'bar' } }, function (err, res, pkg) {
5656
if (err) t.fail(err);
5757
t.equal(res, path.join(dir, 'bar/node_modules/foo/index.js'));
58-
t.equal(pkg, undefined);
58+
t.equal(pkg.main, 'bar');
5959
});
6060
});
6161

@@ -113,7 +113,7 @@ test('biz', function (t) {
113113
resolve('tiv', { basedir: dir + '/grux', 'package': { main: 'grux' } }, function (err, res, pkg) {
114114
if (err) t.fail(err);
115115
t.equal(res, path.join(dir, 'tiv/index.js'));
116-
t.equal(pkg, undefined);
116+
t.equal(pkg.main, 'grux');
117117
});
118118

119119
resolve('tiv', { basedir: dir + '/garply' }, function (err, res, pkg) {
@@ -125,7 +125,7 @@ test('biz', function (t) {
125125
resolve('tiv', { basedir: dir + '/garply', 'package': { main: './lib' } }, function (err, res, pkg) {
126126
if (err) t.fail(err);
127127
t.equal(res, path.join(dir, 'tiv/index.js'));
128-
t.equal(pkg, undefined);
128+
t.equal(pkg.main, './lib');
129129
});
130130

131131
resolve('grux', { basedir: dir + '/tiv' }, function (err, res, pkg) {
@@ -137,7 +137,7 @@ test('biz', function (t) {
137137
resolve('grux', { basedir: dir + '/tiv', 'package': { main: 'tiv' } }, function (err, res, pkg) {
138138
if (err) t.fail(err);
139139
t.equal(res, path.join(dir, 'grux/index.js'));
140-
t.equal(pkg, undefined);
140+
t.equal(pkg.main, 'tiv');
141141
});
142142

143143
resolve('garply', { basedir: dir + '/tiv' }, function (err, res, pkg) {

0 commit comments

Comments
 (0)