| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 365c245 commit a517466
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -201,7 +201,7 @@ code. | |||
| 201 | 201 | <a id="DEP0019"></a> | |
| 202 | 202 | ### DEP0019: require('.') resolved outside directory | |
| 203 | 203 | ||
| 204 | - Type: Runtime | ||
| 204 | + Type: End-of-Life | ||
| 205 | 205 | ||
| 206 | 206 | In certain cases, `require('.')` may resolve outside the package directory. | |
| 207 | 207 | This behavior is deprecated and will be removed in a future major Node.js | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -159,7 +159,6 @@ function tryExtensions(p, exts, isMain) { | |||
| 159 | 159 | return false; | |
| 160 | 160 | } | |
| 161 | 161 | ||
| 162 | - var warned = false; | ||
| 163 | 162 | Module._findPath = function(request, paths, isMain) { | |
| 164 | 163 | if (path.isAbsolute(request)) { | |
| 165 | 164 | paths = ['']; | |
@@ -221,18 +220,6 @@ Module._findPath = function(request, paths, isMain) { | |||
| 221 | 220 | } | |
| 222 | 221 | ||
| 223 | 222 | if (filename) { | |
| 224 | - // Warn once if '.' resolved outside the module dir | ||
| 225 | - if (request === '.' && i > 0) { | ||
| 226 | - if (!warned) { | ||
| 227 | - warned = true; | ||
| 228 | - process.emitWarning( | ||
| 229 | - 'warning: require(\'.\') resolved outside the package ' + | ||
| 230 | - 'directory. This functionality is deprecated and will be removed ' + | ||
| 231 | - 'soon.', | ||
| 232 | - 'DeprecationWarning', 'DEP0019'); | ||
| 233 | - } | ||
| 234 | - } | ||
| 235 | - | ||
| 236 | 223 | Module._pathCache[cacheKey] = filename; | |
| 237 | 224 | return filename; | |
| 238 | 225 | } | |
@@ -335,8 +322,7 @@ Module._resolveLookupPaths = function(request, parent, newReturn) { | |||
| 335 | 322 | } | |
| 336 | 323 | ||
| 337 | 324 | // Check for relative path | |
| 338 | - if (request.length < 2 || | ||
| 339 | - request.charCodeAt(0) !== 46/*.*/ || | ||
| 325 | + if (request.charCodeAt(0) !== 46/*.*/ && | ||
| 340 | 326 | (request.charCodeAt(1) !== 46/*.*/ && | |
| 341 | 327 | request.charCodeAt(1) !== 47/*/*/)) { | |
| 342 | 328 | var paths = modulePaths; | |
@@ -347,16 +333,6 @@ Module._resolveLookupPaths = function(request, parent, newReturn) { | |||
| 347 | 333 | paths = parent.paths.concat(paths); | |
| 348 | 334 | } | |
| 349 | 335 | ||
| 350 | - // Maintain backwards compat with certain broken uses of require('.') | ||
| 351 | - // by putting the module's directory in front of the lookup paths. | ||
| 352 | - if (request === '.') { | ||
| 353 | - if (parent && parent.filename) { | ||
| 354 | - paths.unshift(path.dirname(parent.filename)); | ||
| 355 | - } else { | ||
| 356 | - paths.unshift(path.resolve(request)); | ||
| 357 | - } | ||
| 358 | - } | ||
| 359 | - | ||
| 360 | 336 | debug('looking for %j in %j', request, paths); | |
| 361 | 337 | return (newReturn ? (paths.length > 0 ? paths : null) : [request, paths]); | |
| 362 | 338 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,9 +10,7 @@ const b = require(fixtures.path('module-require', 'relative', 'dot-slash.js')); | |||
| 10 | 10 | assert.strictEqual(a.value, 42); | |
| 11 | 11 | assert.strictEqual(a, b, 'require(".") should resolve like require("./")'); | |
| 12 | 12 | ||
| 13 | + // require('.') should not lookup in NODE_PATH | ||
| 13 | 14 | process.env.NODE_PATH = fixtures.path('module-require', 'relative'); | |
| 14 | 15 | m._initPaths(); | |
| 15 | - | ||
| 16 | - const c = require('.'); | ||
| 17 | - | ||
| 18 | - assert.strictEqual(c.value, 42, 'require(".") should honor NODE_PATH'); | ||
| 16 | + assert.throws(() => { require('.'); }, Error, "Cannot find module '.'"); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments