File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Expand file tree Collapse file tree 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) {
169169 }
170170
171171 if ( filename ) {
172+ if ( request === '.' && i > 0 ) {
173+ console . error ( `(node) warning: require('.') resolved to ${ filename } ` ) ;
174+ }
172175 Module . _pathCache [ cacheKey ] = filename ;
173176 return filename ;
174177 }
@@ -210,12 +213,15 @@ Module._resolveLookupPaths = function(request, parent) {
210213 if ( parent ) {
211214 if ( ! parent . paths ) parent . paths = [ ] ;
212215 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- }
218216 }
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+
219225 return [ request , paths ] ;
220226 }
221227
You can’t perform that action at this time.
0 commit comments