Skip to content

Commit

Permalink
fixup: non-necessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jan 7, 2020
1 parent ec57909 commit b5d1ba7
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions lib/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,27 +271,28 @@ module.exports = function resolve(x, options, callback) {
}

function processDirs(cb, dirs) {
if (dirs.length === 0) return cb(null, undefined);
var dir = dirs[0];
iterate(0);

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

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

function onfile(err, m, pkg) {
if (err) return cb(err);
if (m) return cb(null, m, pkg);
loadAsDirectory(dir, opts.package, ondir);
}
loadAsFile(dir, opts.package, function (err, m, pkg) {
if (err) return cb(err);
if (m) return cb(null, m, pkg);

function ondir(err, n, pkg) {
if (err) return cb(err);
if (n) return cb(null, n, pkg);
processDirs(cb, dirs.slice(1));
loadAsDirectory(dir, opts.package, function (err, n, pkg) {
if (err) return cb(err);
if (n) return cb(null, n, pkg);

iterate(i + 1);
});
});
});
}
}
function loadNodeModules(x, start, cb) {
Expand Down

0 comments on commit b5d1ba7

Please sign in to comment.