Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Commit 421468b

Browse files
danny-andrewsjdalton
authored andcommitted
Quit swallowing errors while trying to find modules (#185)
1 parent 2f72dca commit 421468b

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

src/ModuleCache.js

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,21 @@ export default class ModuleCache extends MapCache {
3737
}
3838

3939
static resolve(id, from=process.cwd()) {
40-
try {
41-
const dirs = path.dirname(Module._resolveFilename(id, _.assign(new Module, {
42-
'paths': Module._nodeModulePaths(from)
43-
}))).split(path.sep);
44-
45-
let { length } = dirs;
46-
while (length--) {
47-
const dirSub = dirs.slice(0, length + 1);
48-
const dirPath = dirSub.join('/');
49-
const pkgPath = path.join(dirPath, 'package.json');
50-
51-
if ((length && dirs[length - 1] == 'node_modules') ||
52-
(fs.existsSync(pkgPath) && require(pkgPath).name == id)) {
53-
return dirPath;
54-
}
40+
const dirs = path.dirname(Module._resolveFilename(id, _.assign(new Module, {
41+
'paths': Module._nodeModulePaths(from)
42+
}))).split(path.sep);
43+
44+
let { length } = dirs;
45+
while (length--) {
46+
const dirSub = dirs.slice(0, length + 1);
47+
const dirPath = dirSub.join('/');
48+
const pkgPath = path.join(dirPath, 'package.json');
49+
50+
if ((length && dirs[length - 1] == 'node_modules') ||
51+
(fs.existsSync(pkgPath) && require(pkgPath).name == id)) {
52+
return dirPath;
5553
}
56-
return dirs.join('/');
57-
} catch (e) {}
58-
return '';
54+
}
55+
return dirs.join('/');
5956
}
6057
};

0 commit comments

Comments
 (0)