Skip to content

Commit 5ebb39a

Browse files
author
James Halliday
committed
flatter nodeModules function
1 parent 70146a5 commit 5ebb39a

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

lib/async.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,20 @@ module.exports = function resolve (x, opts, cb) {
171171
if (dirs.length === 0) return cb(null, undefined);
172172
var dir = dirs[0];
173173

174-
loadAsFile(path.join(dir, '/', x), undefined, function (err, m, pkg) {
174+
var file = path.join(dir, '/', x);
175+
loadAsFile(file, undefined, onfile);
176+
177+
function onfile (err, m, pkg) {
175178
if (err) return cb(err);
176179
if (m) return cb(null, m, pkg);
177-
loadAsDirectory(path.join(dir, '/', x), undefined, function (err, n, pkg) {
178-
if (err) return cb(err);
179-
if (n) return cb(null, n, pkg);
180-
process(dirs.slice(1));
181-
});
182-
});
180+
loadAsDirectory(path.join(dir, '/', x), undefined, ondir);
181+
}
182+
183+
function ondir (err, n, pkg) {
184+
if (err) return cb(err);
185+
if (n) return cb(null, n, pkg);
186+
process(dirs.slice(1));
187+
}
183188
})(nodeModulesPaths(start, opts));
184189
}
185190
};

0 commit comments

Comments
 (0)