forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
module: replace default paths in require.resolve()
Prior to this commit, the default search paths would be included in the require.resolve() process, even if user specified paths were provided. This commit causes the default paths to be omitted by using a fake parent module. Refs: nodejs#5963 PR-URL: nodejs#17113 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
Showing
5 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
require('../../../common'); | ||
const assert = require('assert'); | ||
const path = require('path'); | ||
|
||
// By default, resolving 'dep' should return | ||
// fixturesDir/resolve-paths/default/node_modules/dep/index.js. By setting | ||
// the path to fixturesDir/resolve-paths/default, the 'default' directory | ||
// structure should be ignored. | ||
|
||
assert.strictEqual( | ||
require.resolve('dep'), | ||
path.join(__dirname, 'node_modules', 'dep', 'index.js') | ||
); | ||
|
||
const paths = [path.resolve(__dirname, '..', 'defined')]; | ||
|
||
assert.strictEqual( | ||
require.resolve('dep', { paths }), | ||
path.join(paths[0], 'node_modules', 'dep', 'index.js') | ||
); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters