findup
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -14,2 +14,3 @@ var fs = require('fs'), | ||
if (dir === '/') return cb(new Error('not found')); | ||
if(dir.indexOf('../../') !== -1 ) return cb(new Error(dir + ' is not correct.')); | ||
iterator(dir, function(exists){ | ||
@@ -28,3 +29,5 @@ if(exists) return cb(null, dir); | ||
} | ||
var initialDir = dir; | ||
while(dir !== '/'){ | ||
if(dir.indexOf('../../') !== -1 ) throw new Error(initialDir + ' is not correct.'); | ||
if(iteratorSync(dir)) return dir; | ||
@@ -31,0 +34,0 @@ dir = Path.join(dir, '..'); |
@@ -5,3 +5,3 @@ { | ||
"description": "Walk up ancester's dir up to root", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -57,2 +57,12 @@ var vows = require('vows'), | ||
'When findup in a bullshit dir': { | ||
topic: function(fixtureDir){ | ||
findup('dsqkjfnqsdkjghq', 'toto.json', this.callback); | ||
}, | ||
'Then an error is returned': function(err, file){ | ||
assert.isNotNull(err); | ||
} | ||
}, | ||
'When findup a file in ancestors dir in synchronous mode': { | ||
@@ -90,4 +100,18 @@ topic: function(fixtureDir){ | ||
} | ||
}, | ||
'When findup in a bullshit dir in synchronous mode': { | ||
topic: function(fixtureDir){ | ||
try{ | ||
return findup.sync('uhjhbjkg,nfg', 'toto.json'); | ||
}catch(e){ | ||
return e; | ||
} | ||
}, | ||
'Then an error is returned': function(err){ | ||
assert.isNotNull(err); | ||
} | ||
} | ||
} | ||
}).exportTo(module); |
6752
140