Skip to content

Commit b5d1ba7

Browse files
committed
fixup: non-necessary changes
1 parent ec57909 commit b5d1ba7

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

lib/async.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -271,27 +271,28 @@ module.exports = function resolve(x, options, callback) {
271271
}
272272

273273
function processDirs(cb, dirs) {
274-
if (dirs.length === 0) return cb(null, undefined);
275-
var dir = dirs[0];
274+
iterate(0);
276275

277-
isDirectory(path.dirname(dir), isdir);
276+
function iterate(i) {
277+
if (i === dirs.length) return cb(null, undefined);
278+
var dir = dirs[i];
278279

279-
function isdir(err, isdir) {
280-
if (err) return cb(err);
281-
if (!isdir) return processDirs(cb, dirs.slice(1));
282-
loadAsFile(dir, opts.package, onfile);
283-
}
280+
isDirectory(path.dirname(dir), function (err, status) {
281+
if (err) return cb(err);
282+
if (!status) return iterate(i + 1);
284283

285-
function onfile(err, m, pkg) {
286-
if (err) return cb(err);
287-
if (m) return cb(null, m, pkg);
288-
loadAsDirectory(dir, opts.package, ondir);
289-
}
284+
loadAsFile(dir, opts.package, function (err, m, pkg) {
285+
if (err) return cb(err);
286+
if (m) return cb(null, m, pkg);
290287

291-
function ondir(err, n, pkg) {
292-
if (err) return cb(err);
293-
if (n) return cb(null, n, pkg);
294-
processDirs(cb, dirs.slice(1));
288+
loadAsDirectory(dir, opts.package, function (err, n, pkg) {
289+
if (err) return cb(err);
290+
if (n) return cb(null, n, pkg);
291+
292+
iterate(i + 1);
293+
});
294+
});
295+
});
295296
}
296297
}
297298
function loadNodeModules(x, start, cb) {

0 commit comments

Comments
 (0)