Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert the gitignore changes; it's unrelated to this PR.

2 changes: 1 addition & 1 deletion lib/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = function resolve (x, opts, cb) {

if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[\\\/])/.test(x)) {
var res = path.resolve(y, x);
if (x === '..') res += '/';
if (x === '..' || x[x.length-1] === '/') res += path.sep;
loadAsFile(res, function (err, m, pkg) {
if (err) cb(err)
else if (m) cb(null, m, pkg)
Expand Down
2 changes: 1 addition & 1 deletion lib/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function (x, opts) {

if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[\\\/])/.test(x)) {
var res = path.resolve(y, x);
if (x === '..') res += '/';
if (x === '..' || x[x.length-1] === '/') res += path.sep;
var m = loadAsFileSync(res) || loadAsDirectorySync(res);
if (m) return m;
} else {
Expand Down
12 changes: 12 additions & 0 deletions test/issue51.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var test = require('tap').test;
var resolve = require('../');
var path = require('path')

test('issue 51', function (t) {
t.ok(resolve.sync('./issue51/test/') === path.resolve(__dirname, 'issue51/test/index.js'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also ensure that ./issue51/test/ is not equal to ./issue51/test when there's a test.js file?

resolve('./issue51/test/', function(e, result) {
if(e) throw e
t.ok(result === path.resolve(__dirname, 'issue51/test/index.js'));
t.end();
})
});
1 change: 1 addition & 0 deletions test/issue51/moo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require('./test/')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a trailing newline on this file

1 change: 1 addition & 0 deletions test/issue51/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('file')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a trailing newline on this file

1 change: 1 addition & 0 deletions test/issue51/test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('folder')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a trailing newline on this file