2017-06-06 00:44:56 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const { spawn } = require('child_process');
|
|
|
|
const assert = require('assert');
|
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
2017-12-25 06:38:11 +00:00
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
|
|
tmpdir.refresh();
|
|
|
|
const tmpDir = tmpdir.path;
|
2017-06-06 00:44:56 +00:00
|
|
|
|
|
|
|
const entry = path.join(tmpDir, 'entry.mjs');
|
|
|
|
const real = path.join(tmpDir, 'index.mjs');
|
2018-08-28 15:28:46 +00:00
|
|
|
const link_absolute_path = path.join(tmpDir, 'absolute.mjs');
|
|
|
|
const link_relative_path = path.join(tmpDir, 'relative.mjs');
|
2017-06-06 00:44:56 +00:00
|
|
|
const link_ignore_extension = path.join(tmpDir,
|
|
|
|
'ignore_extension.json');
|
|
|
|
const link_directory = path.join(tmpDir, 'directory');
|
|
|
|
|
|
|
|
fs.writeFileSync(real, 'export default [];');
|
|
|
|
fs.writeFileSync(entry, `
|
|
|
|
import assert from 'assert';
|
|
|
|
import real from './index.mjs';
|
2018-08-28 15:28:46 +00:00
|
|
|
import absolute from './absolute.mjs';
|
|
|
|
import relative from './relative.mjs';
|
2017-06-06 00:44:56 +00:00
|
|
|
import ignoreExtension from './ignore_extension.json';
|
|
|
|
|
|
|
|
assert.strictEqual(absolute, real);
|
|
|
|
assert.strictEqual(relative, real);
|
|
|
|
assert.strictEqual(ignoreExtension, real);
|
|
|
|
`);
|
|
|
|
|
|
|
|
try {
|
|
|
|
fs.symlinkSync(real, link_absolute_path);
|
|
|
|
fs.symlinkSync(path.basename(real), link_relative_path);
|
|
|
|
fs.symlinkSync(real, link_ignore_extension);
|
2018-02-27 22:24:21 +00:00
|
|
|
fs.symlinkSync(path.dirname(real), link_directory, 'dir');
|
2017-06-06 00:44:56 +00:00
|
|
|
} catch (err) {
|
|
|
|
if (err.code !== 'EPERM') throw err;
|
|
|
|
common.skip('insufficient privileges for symlinks');
|
|
|
|
}
|
|
|
|
|
2019-10-11 21:57:13 +00:00
|
|
|
spawn(process.execPath, [entry],
|
2017-06-06 00:44:56 +00:00
|
|
|
{ stdio: 'inherit' }).on('exit', (code) => {
|
|
|
|
assert.strictEqual(code, 0);
|
|
|
|
});
|