Skip to content

Commit e7bffbf

Browse files
author
James Halliday
committed
nearly nearly working
1 parent 644f814 commit e7bffbf

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/async.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = function resolve (x, opts, cb) {
3737
loadAsFile(res, opts.package, function (err, m, pkg) {
3838
if (err) cb(err)
3939
else if (m) cb(null, m, pkg)
40-
else loadAsDirectory(path.resolve(y, x), function (err, d, pkg) {
40+
else loadAsDirectory(res, function (err, d, pkg) {
4141
if (err) cb(err)
4242
else if (d) cb(null, d, pkg)
4343
else cb(new Error("Cannot find module '" + x + "' from '" + y + "'"))
@@ -51,20 +51,21 @@ module.exports = function resolve (x, opts, cb) {
5151
else cb(new Error("Cannot find module '" + x + "' from '" + y + "'"))
5252
});
5353

54-
function loadAsFile (x, pkg, cb) {
54+
function loadAsFile (x, pkg, cb, again) {
5555
if (typeof pkg === 'function') {
5656
cb = pkg;
5757
pkg = undefined;
5858
}
5959

6060
var exts = [''].concat(extensions);
6161

62-
if (x === y) {
63-
return loadAsDirectory(y, pkg, cb);
64-
}
65-
else {
66-
return load(exts, x, pkg);
62+
if (x === y && !again) {
63+
loadAsDirectory(y, pkg, function (err, d, pkg) {
64+
if (d) cb(err, d, pkg)
65+
else loadAsFile(x, pkg, cb, true)
66+
});
6767
}
68+
else load(exts, x, pkg)
6869

6970
function load (exts, x, pkg) {
7071
if (exts.length === 0) return cb(null, undefined, pkg);

0 commit comments

Comments
 (0)