Skip to content

Commit b7ba83d

Browse files
committed
[Fix] sync: ensure that the path is a string, explicitly.
Also, make the sync/async error messages here the same, and ensure it works in node 0.6 (which doesn’t throw on non-strings in `path.join`)
1 parent 1de578f commit b7ba83d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/async.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = function resolve(x, options, callback) {
1212
opts = {};
1313
}
1414
if (typeof x !== 'string') {
15-
var err = new TypeError('path must be a string');
15+
var err = new TypeError('Path must be a string.');
1616
return process.nextTick(function () {
1717
cb(err);
1818
});

lib/sync.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ var caller = require('./caller.js');
55
var nodeModulesPaths = require('./node-modules-paths.js');
66

77
module.exports = function (x, options) {
8+
if (typeof x !== 'string') {
9+
throw new TypeError('Path must be a string.');
10+
}
811
var opts = options || {};
912
var isFile = opts.isFile || function (file) {
1013
try {

0 commit comments

Comments
 (0)