11cb0ef41Sopenharmony_ciimport * as common from '../common/index.mjs'; 21cb0ef41Sopenharmony_ciimport path from 'path'; 31cb0ef41Sopenharmony_ciimport fs from 'fs/promises'; 41cb0ef41Sopenharmony_ciimport tmpdir from '../common/tmpdir.js'; 51cb0ef41Sopenharmony_ciimport { spawn } from 'child_process'; 61cb0ef41Sopenharmony_ciimport assert from 'assert'; 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_citmpdir.refresh(); 91cb0ef41Sopenharmony_ciconst tmpDir = tmpdir.path; 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ci// Create the following file structure: 121cb0ef41Sopenharmony_ci// ├── index.mjs 131cb0ef41Sopenharmony_ci// ├── subfolder 141cb0ef41Sopenharmony_ci// │ ├── index.mjs 151cb0ef41Sopenharmony_ci// │ └── node_modules 161cb0ef41Sopenharmony_ci// │ └── package-a 171cb0ef41Sopenharmony_ci// │ └── index.mjs 181cb0ef41Sopenharmony_ci// └── symlink.mjs -> ./subfolder/index.mjs 191cb0ef41Sopenharmony_ciconst entry = path.join(tmpDir, 'index.mjs'); 201cb0ef41Sopenharmony_ciconst symlink = path.join(tmpDir, 'symlink.mjs'); 211cb0ef41Sopenharmony_ciconst real = path.join(tmpDir, 'subfolder', 'index.mjs'); 221cb0ef41Sopenharmony_ciconst packageDir = path.join(tmpDir, 'subfolder', 'node_modules', 'package-a'); 231cb0ef41Sopenharmony_ciconst packageEntry = path.join(packageDir, 'index.mjs'); 241cb0ef41Sopenharmony_citry { 251cb0ef41Sopenharmony_ci await fs.symlink(real, symlink); 261cb0ef41Sopenharmony_ci} catch (err) { 271cb0ef41Sopenharmony_ci if (err.code !== 'EPERM') throw err; 281cb0ef41Sopenharmony_ci common.skip('insufficient privileges for symlinks'); 291cb0ef41Sopenharmony_ci} 301cb0ef41Sopenharmony_ciawait fs.mkdir(packageDir, { recursive: true }); 311cb0ef41Sopenharmony_ciawait Promise.all([ 321cb0ef41Sopenharmony_ci fs.writeFile(entry, 'import "./symlink.mjs";'), 331cb0ef41Sopenharmony_ci fs.writeFile(real, 'export { a } from "package-a/index.mjs"'), 341cb0ef41Sopenharmony_ci fs.writeFile(packageEntry, 'export const a = 1;'), 351cb0ef41Sopenharmony_ci]); 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_cispawn(process.execPath, ['--experimental-specifier-resolution=node', entry], 381cb0ef41Sopenharmony_ci { stdio: 'inherit' }).on('exit', common.mustCall((code) => { 391cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 401cb0ef41Sopenharmony_ci})); 41