File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -24,14 +24,18 @@ module.exports = {
24
24
// Similar to native `require` behavior, but doesn't check in `node_modules` folders
25
25
// Based on https://github.com/js-cli/node-findup-sync
26
26
function requireUp ( filename , cwd ) {
27
- var filepath = path . resolve ( cwd , filename ) ;
27
+ var filepath = path . resolve ( cwd , filename ) + exts [ i ] ;
28
28
29
29
for ( var i = 0 ; i < exts . length ; i ++ ) {
30
30
try {
31
- return require ( filepath + exts [ i ] ) ;
31
+ return require ( filepath ) ;
32
32
} catch ( error ) {
33
- // Ignore OS errors (will recurse to parent directory)
34
- if ( error . code !== 'MODULE_NOT_FOUND' ) {
33
+ var filepathNotFound = error . code === 'MODULE_NOT_FOUND' &&
34
+ error . message . includes ( `Cannot find module '${ filepath } '` ) ;
35
+
36
+ // Rethrow unless error is just saying `filepath` not found (in that case,
37
+ // let next loop check parent directory instead).
38
+ if ( ! filepathNotFound ) {
35
39
throw error ;
36
40
}
37
41
}
You can’t perform that action at this time.
0 commit comments