Skip to content

Commit

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

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

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

isDirectory(path.dirname(dir), function (err, status) {
if (err) return cb(err);
if (!status) return iterate(i + 1);

loadAsFile(dir, opts.package, function (err, m, pkg) {
if (err) return cb(err);
if (m) return cb(null, m, pkg);
function isdir(err, isdir) {
if (err) return cb(err);
if (!isdir) return processDirs(cb, dirs.slice(1));
loadAsFile(dir, opts.package, onfile);
}

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

iterate(i + 1);
});
});
});
function ondir(err, n, pkg) {
if (err) return cb(err);
if (n) return cb(null, n, pkg);
processDirs(cb, dirs.slice(1));
}
}
function loadNodeModules(x, start, cb) {
Expand Down

0 comments on commit 99aa42e

Please sign in to comment.