Skip to content

Commit

Permalink
resolve '../baz' correct
Browse files Browse the repository at this point in the history
  • Loading branch information
kesla committed Nov 12, 2012
1 parent d1c1012 commit 46fe923
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ exports.sync = function (x, opts) {
var m = loadAsFileSync(path.resolve(y, x))
|| loadAsDirectorySync(path.resolve(y, x));
if (m) return m;
} else {
var n = loadNodeModulesSync(x, y);
if (n) return n;
}

var n = loadNodeModulesSync(x, y);
if (n) return n;

throw new Error("Cannot find module '" + x + "'");

function loadAsFileSync (x) {
Expand Down
6 changes: 5 additions & 1 deletion test/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var test = require('tap').test;
var resolve = require('../');

test('mock', function (t) {
t.plan(3);
t.plan(4);

var files = {
'/foo/bar/baz.js' : 'beep'
Expand Down Expand Up @@ -33,6 +33,10 @@ test('mock', function (t) {
t.throws(function () {
resolve.sync('baz', opts('/foo/bar'));
});

t.throws(function () {
resolve.sync('../baz', opts('/foo/bar'));
});
});

test('mock package', function (t) {
Expand Down

0 comments on commit 46fe923

Please sign in to comment.