Skip to content
Browse files

Avoid infinite recursion when CWD is outside of `/` on Windows.

When traversing upwards, it's possible `/` maps to a different drive
than where the CWD is (usually, `C:\\`).
  • Loading branch information...
1 parent c65dc2f commit fec31715e14233cf002d6915e8d97b6e96d650a7 @brentlintner brentlintner committed Apr 30, 2012
Showing with 3 additions and 4 deletions.
  1. +3 −4 lib/cli.js
View
7 lib/cli.js
@@ -3,7 +3,6 @@ var fs = require('fs'),
cli = require('cli').enable('glob', 'help'),
hint = require('./hint');
-var rootPath = path.resolve("/");
function existsSync() {
var obj = fs.existsSync ? fs : path;
return obj.existsSync.apply(obj, arguments);
@@ -32,14 +31,14 @@ function _loadAndParseConfig(filePath) {
function _searchFile(name, dir) {
dir = dir || process.cwd();
- var filename = path.normalize(path.join(dir, name));
+ var filename = path.normalize(path.join(dir, name)),
+ parent = path.resolve(dir, "..");
if (existsSync(filename)) {
return filename;
}
- return dir === rootPath ?
- null : _searchFile(name, path.normalize(path.join(dir, "..")));
+ return dir === parent ? null : _searchFile(name, parent);
}
function _findConfig(target) {

0 comments on commit fec3171

Please sign in to comment.
Something went wrong with that request. Please try again.