| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9c0c336 commit caff930
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -518,11 +518,14 @@ Module._resolveFilename = function(request, parent, isMain, options) { | |||
| 518 | 518 | ||
| 519 | 519 | if (typeof options === 'object' && options !== null && | |
| 520 | 520 | Array.isArray(options.paths)) { | |
| 521 | + const fakeParent = new Module('', null); | ||
| 522 | + | ||
| 521 | 523 | paths = []; | |
| 522 | 524 | ||
| 523 | 525 | for (var i = 0; i < options.paths.length; i++) { | |
| 524 | 526 | const path = options.paths[i]; | |
| 525 | - const lookupPaths = Module._resolveLookupPaths(path, parent, true); | ||
| 527 | + fakeParent.paths = Module._nodeModulePaths(path); | ||
| 528 | + const lookupPaths = Module._resolveLookupPaths(request, fakeParent, true); | ||
| 526 | 529 | ||
| 527 | 530 | if (!paths.includes(path)) | |
| 528 | 531 | paths.push(path); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,21 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + require('../../../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const path = require('path'); | ||
| 5 | + | ||
| 6 | + // By default, resolving 'dep' should return | ||
| 7 | + // fixturesDir/resolve-paths/default/node_modules/dep/index.js. By setting | ||
| 8 | + // the path to fixturesDir/resolve-paths/default, the 'default' directory | ||
| 9 | + // structure should be ignored. | ||
| 10 | + | ||
| 11 | + assert.strictEqual( | ||
| 12 | + require.resolve('dep'), | ||
| 13 | + path.join(__dirname, 'node_modules', 'dep', 'index.js') | ||
| 14 | + ); | ||
| 15 | + | ||
| 16 | + const paths = [path.resolve(__dirname, '..', 'defined')]; | ||
| 17 | + | ||
| 18 | + assert.strictEqual( | ||
| 19 | + require.resolve('dep', { paths }), | ||
| 20 | + path.join(paths[0], 'node_modules', 'dep', 'index.js') | ||
| 21 | + ); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,3 +37,4 @@ assert.strictEqual('path', require.resolve('path')); | |||
| 37 | 37 | ||
| 38 | 38 | // Test configurable resolve() paths. | |
| 39 | 39 | require(fixtures.path('require-resolve.js')); | |
| 40 | + require(fixtures.path('resolve-paths', 'default', 'verify-paths.js')); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments