2018-03-16 19:17:42 +08:00
|
|
|
'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');
|
2018-08-28 23:28:46 +08:00
|
|
|
const symlinkPath = path.resolve(tmpdir.path, 'symlink.mjs');
|
2018-03-16 19:17:42 +08:00
|
|
|
|
|
|
|
try {
|
|
|
|
fs.symlinkSync(realPath, symlinkPath);
|
|
|
|
} catch (err) {
|
|
|
|
if (err.code !== 'EPERM') throw err;
|
|
|
|
common.skip('insufficient privileges for symlinks');
|
|
|
|
}
|
|
|
|
|
|
|
|
spawn(process.execPath,
|
2019-10-12 05:57:13 +08:00
|
|
|
['--preserve-symlinks', symlinkPath],
|
2018-03-16 19:17:42 +08:00
|
|
|
{ stdio: 'inherit' }).on('exit', (code) => {
|
|
|
|
assert.strictEqual(code, 0);
|
|
|
|
});
|