summaryrefslogtreecommitdiff
path: root/test/es-module/test-esm-symlink-main.js
blob: f7631ef2e5bdcaaca2b72829303fb7eca8a51558 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'use strict';

const common = require('../common');
const assert = require('assert');
const path = require('path');
const { spawn } = require('child_process');
const tmpdir = require('../common/tmpdir');
const fs = require('fs');
tmpdir.refresh();

const realPath = path.resolve(__dirname, '../fixtures/es-modules/symlink.mjs');
const symlinkPath = path.resolve(tmpdir.path, 'symlink.js');

try {
  fs.symlinkSync(realPath, symlinkPath);
} catch (err) {
  if (err.code !== 'EPERM') throw err;
  common.skip('insufficient privileges for symlinks');
}

spawn(process.execPath,
      ['--experimental-modules', '--preserve-symlinks', symlinkPath],
      { stdio: 'inherit' }).on('exit', (code) => {
  assert.strictEqual(code, 0);
});