xref: /third_party/node/test/parallel/test-module-relative-lookup.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ciconst _module = require('module'); // Avoid collision with global.module
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci// Current directory gets highest priority for local modules
81cb0ef41Sopenharmony_cifunction testFirstInPath(moduleName, isLocalModule) {
91cb0ef41Sopenharmony_ci  const assertFunction = isLocalModule ?
101cb0ef41Sopenharmony_ci    assert.strictEqual :
111cb0ef41Sopenharmony_ci    assert.notStrictEqual;
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ci  let paths = _module._resolveLookupPaths(moduleName);
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci  assertFunction(paths[0], '.');
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci  paths = _module._resolveLookupPaths(moduleName, null);
181cb0ef41Sopenharmony_ci  assertFunction(paths && paths[0], '.');
191cb0ef41Sopenharmony_ci}
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_citestFirstInPath('./lodash', true);
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ci// Relative path on Windows, but a regular file name elsewhere
241cb0ef41Sopenharmony_citestFirstInPath('.\\lodash', common.isWindows);
25

Indexes created Thu Nov 07 10:32:03 CST 2024