File tree 1 file changed +11
-5
lines changed
1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,9 @@ Module._findPath = function(request, paths) {
169
169
}
170
170
171
171
if ( filename ) {
172
+ if ( request === '.' && i > 0 ) {
173
+ console . error ( `(node) warning: require('.') resolved to ${ filename } ` ) ;
174
+ }
172
175
Module . _pathCache [ cacheKey ] = filename ;
173
176
return filename ;
174
177
}
@@ -210,12 +213,15 @@ Module._resolveLookupPaths = function(request, parent) {
210
213
if ( parent ) {
211
214
if ( ! parent . paths ) parent . paths = [ ] ;
212
215
paths = parent . paths . concat ( paths ) ;
213
- // For '.', put PWD at the front of the resolve paths
214
- // TODO(silverwind): Treat '.' exactly the same as './'
215
- if ( request === '.' ) {
216
- paths . splice ( 0 , 0 , path . resolve ( request ) ) ;
217
- }
218
216
}
217
+
218
+ // For '.', put the module's dir at the front of the resolve paths
219
+ // TODO(silverwind): Treat '.' exactly the same as './'
220
+ if ( request === '.' ) {
221
+ paths . splice ( 0 , 0 , parent && parent . filename ?
222
+ path . dirname ( parent . filename ) : path . resolve ( 'request' ) ) ;
223
+ }
224
+
219
225
return [ request , paths ] ;
220
226
}
221
227
You can’t perform that action at this time.
0 commit comments