|
1 | | -import { spawnPromisified } from '../common/index.mjs'; |
| 1 | +import { canCreateSymLink, spawnPromisified } from '../common/index.mjs'; |
2 | 2 | import * as fixtures from '../common/fixtures.mjs'; |
3 | 3 | import tmpdir from '../common/tmpdir.js'; |
4 | 4 | import assert from 'node:assert'; |
5 | | -import { writeFileSync } from 'node:fs'; |
| 5 | +import { symlinkSync, writeFileSync } from 'node:fs'; |
| 6 | +import path from 'node:path'; |
6 | 7 | import { execPath } from 'node:process'; |
7 | 8 | import { describe, it } from 'node:test'; |
8 | 9 | import { pathToFileURL } from 'node:url'; |
@@ -375,4 +376,28 @@ describe('ESM: --experimental-package-map', () => { |
375 | 376 | assert.notStrictEqual(code, 0, stderr); |
376 | 377 | }); |
377 | 378 | }); |
| 379 | + |
| 380 | + // =========== Symlink in Ancestor =========== |
| 381 | + |
| 382 | + describe('symlink in ancestor of package map', { |
| 383 | + skip: !canCreateSymLink() && 'insufficient privileges for symlinks', |
| 384 | + }, () => { |
| 385 | + const symlinkDir = tmpdir.resolve('symlinked-package-map-esm'); |
| 386 | + symlinkSync(fixtures.path('package-map'), symlinkDir, 'dir'); |
| 387 | + |
| 388 | + it('resolves through a symlinked ancestor directory', async () => { |
| 389 | + const symlinkMapPath = path.join(symlinkDir, 'package-map.json'); |
| 390 | + const { code, stdout, stderr } = await spawnPromisified(execPath, [ |
| 391 | + '--no-warnings', |
| 392 | + '--experimental-package-map', symlinkMapPath, |
| 393 | + '--input-type=module', |
| 394 | + '--eval', |
| 395 | + `import dep from 'dep-a'; console.log(dep);`, |
| 396 | + ], { cwd: fixtures.path('package-map/root') }); |
| 397 | + |
| 398 | + assert.strictEqual(stderr, ''); |
| 399 | + assert.match(stdout, /dep-a-value/); |
| 400 | + assert.strictEqual(code, 0, stderr); |
| 401 | + }); |
| 402 | + }); |
378 | 403 | }); |
0 commit comments