Skip to content

Commit c8a6050

Browse files
arcanisljharb
authored andcommitted
fixup: reverts non-necessary changes
1 parent b5d1ba7 commit c8a6050

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

lib/async.js

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

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

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

280-
isDirectory(path.dirname(dir), function (err, status) {
281-
if (err) return cb(err);
282-
if (!status) return iterate(i + 1);
283-
284-
loadAsFile(dir, opts.package, function (err, m, pkg) {
285-
if (err) return cb(err);
286-
if (m) return cb(null, m, pkg);
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+
}
287284

288-
loadAsDirectory(dir, opts.package, function (err, n, pkg) {
289-
if (err) return cb(err);
290-
if (n) return cb(null, n, pkg);
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+
}
291290

292-
iterate(i + 1);
293-
});
294-
});
295-
});
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));
296295
}
297296
}
298297
function loadNodeModules(x, start, cb) {

0 commit comments

Comments
 (0)