GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — node/test/es-module/test-esm-preserve-symlinks-main.js at master · ferventcoder/node Expand file tree/ Copy pathtest-esm-preserve-symlinks-main.jsMore file actions 57 lines (48 loc) · 1.76 KB / Copy pathtest-esm-preserve-symlinks-main.jsFile metadata and controls57 lines (48 loc) · 1.76 KB 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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 '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; fs.mkdirSync(path.join(tmpDir, 'nested')); fs.mkdirSync(path.join(tmpDir, 'nested2')); const entry = path.join(tmpDir, 'nested', 'entry.js'); const entry_link_absolute_path = path.join(tmpDir, 'link.js'); const submodule = path.join(tmpDir, 'nested2', 'submodule.js'); const submodule_link_absolute_path = path.join(tmpDir, 'submodule_link.js'); fs.writeFileSync(entry, ` const assert = require('assert'); // this import only resolves with --preserve-symlinks-main set require('./submodule_link.js'); `); fs.writeFileSync(submodule, ''); try { fs.symlinkSync(entry, entry_link_absolute_path); fs.symlinkSync(submodule, submodule_link_absolute_path); } catch (err) { if (err.code !== 'EPERM') throw err; common.skip('insufficient privileges for symlinks'); } function doTest(flags, done) { // invoke the main file via a symlink. In this case --preserve-symlinks-main // dictates that it'll resolve relative imports in the main file relative to // the symlink, and not relative to the symlink target; the file structure set // up above requires this to not crash when loading ./submodule_link.js spawn(process.execPath, flags.concat([ '--preserve-symlinks', '--preserve-symlinks-main', entry_link_absolute_path ]), { stdio: 'inherit' }).on('exit', (code) => { assert.strictEqual(code, 0); done(); }); } // first test the commonjs module loader doTest([], () => { // now test the new loader doTest(['--experimental-modules'], () => {}); }); |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |