xref: /third_party/node/test/es-module/test-esm-symlink-main.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/es-module/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ciconst path = require('path');
61cb0ef41Sopenharmony_ciconst { spawn } = require('child_process');
71cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir');
81cb0ef41Sopenharmony_ciconst fs = require('fs');
91cb0ef41Sopenharmony_citmpdir.refresh();
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst realPath = path.resolve(__dirname, '../fixtures/es-modules/symlink.mjs');
121cb0ef41Sopenharmony_ciconst symlinkPath = path.resolve(tmpdir.path, 'symlink.mjs');
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_citry {
151cb0ef41Sopenharmony_ci  fs.symlinkSync(realPath, symlinkPath);
161cb0ef41Sopenharmony_ci} catch (err) {
171cb0ef41Sopenharmony_ci  if (err.code !== 'EPERM') throw err;
181cb0ef41Sopenharmony_ci  common.skip('insufficient privileges for symlinks');
191cb0ef41Sopenharmony_ci}
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_cispawn(process.execPath,
221cb0ef41Sopenharmony_ci      ['--preserve-symlinks', symlinkPath],
231cb0ef41Sopenharmony_ci      { stdio: 'inherit' }).on('exit', (code) => {
241cb0ef41Sopenharmony_ci  assert.strictEqual(code, 0);
251cb0ef41Sopenharmony_ci});
26

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