0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-module-relative-lookup.js
Aviv Keller 574f2dd517
lib: prefer optional chaining
PR-URL: https://github.com/nodejs/node/pull/55045
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2024-09-24 19:48:15 +00:00

25 lines
701 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const _module = require('module'); // Avoid collision with global.module
// Current directory gets highest priority for local modules
function testFirstInPath(moduleName, isLocalModule) {
const assertFunction = isLocalModule ?
assert.strictEqual :
assert.notStrictEqual;
let paths = _module._resolveLookupPaths(moduleName);
assertFunction(paths[0], '.');
paths = _module._resolveLookupPaths(moduleName, null);
assertFunction(paths?.[0], '.');
}
testFirstInPath('./lodash', true);
// Relative path on Windows, but a regular file name elsewhere
testFirstInPath('.\\lodash', common.isWindows);