mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
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: https://github.com/nodejs/node/issues/5963 PR-URL: https://github.com/nodejs/node/pull/17113 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
22 lines
618 B
JavaScript
22 lines
618 B
JavaScript
'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')
|
|
);
|