Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve '../baz' correct #16

Merged
1 commit merged into from Feb 18, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions index.js
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
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