mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 07:27:22 +01:00
fddcd6253b
Also consistently import the `common` module where possible. PR-URL: https://github.com/nodejs/node/pull/19409 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
39 lines
968 B
JavaScript
39 lines
968 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { spawn } = require('child_process');
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
tmpdir.refresh();
|
|
const tmpDir = tmpdir.path;
|
|
|
|
const entry = path.join(tmpDir, 'entry.js');
|
|
const real = path.join(tmpDir, 'real.js');
|
|
const link_absolute_path = path.join(tmpDir, 'link.js');
|
|
|
|
fs.writeFileSync(entry, `
|
|
const assert = require('assert');
|
|
global.x = 0;
|
|
require('./real.js');
|
|
assert.strictEqual(x, 1);
|
|
require('./link.js');
|
|
assert.strictEqual(x, 2);
|
|
`);
|
|
fs.writeFileSync(real, 'x++;');
|
|
|
|
try {
|
|
fs.symlinkSync(real, link_absolute_path);
|
|
} catch (err) {
|
|
if (err.code !== 'EPERM') throw err;
|
|
common.skip('insufficient privileges for symlinks');
|
|
}
|
|
|
|
spawn(process.execPath,
|
|
['--experimental-modules', '--preserve-symlinks', entry],
|
|
{ stdio: 'inherit' }).on('exit', (code) => {
|
|
assert.strictEqual(code, 0);
|
|
});
|