2016-03-13 21:40:38 +01:00
|
|
|
'use strict';
|
|
|
|
|
2018-08-08 03:58:06 +01:00
|
|
|
const common = require('../common');
|
2016-03-13 21:40:38 +01:00
|
|
|
const assert = require('assert');
|
2025-01-22 15:30:30 -08:00
|
|
|
const _module = require('module'); // Avoid collision with globalThis.module
|
2016-03-13 21:40:38 +01:00
|
|
|
|
2018-05-06 19:42:50 +05:30
|
|
|
// Current directory gets highest priority for local modules
|
2018-08-08 03:58:06 +01:00
|
|
|
function testFirstInPath(moduleName, isLocalModule) {
|
|
|
|
const assertFunction = isLocalModule ?
|
|
|
|
assert.strictEqual :
|
|
|
|
assert.notStrictEqual;
|
2017-01-13 05:22:27 -05:00
|
|
|
|
2019-03-29 14:46:53 +01:00
|
|
|
let paths = _module._resolveLookupPaths(moduleName);
|
2017-01-13 05:22:27 -05:00
|
|
|
|
2018-08-08 03:58:06 +01:00
|
|
|
assertFunction(paths[0], '.');
|
|
|
|
|
2019-03-29 14:46:53 +01:00
|
|
|
paths = _module._resolveLookupPaths(moduleName, null);
|
2024-09-24 15:48:15 -04:00
|
|
|
assertFunction(paths?.[0], '.');
|
2018-08-08 03:58:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
testFirstInPath('./lodash', true);
|
|
|
|
|
|
|
|
// Relative path on Windows, but a regular file name elsewhere
|
|
|
|
testFirstInPath('.\\lodash', common.isWindows);
|