Files
node/test/parallel/test-vfs-fs-linkSync.js
Matteo Collina 49ad95045a vfs: unflag
Enable node:vfs by default. --no-experimental-vfs disables node:vfs
exposure and --vfs-load.

Assisted-by: pi
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/66318
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2026-10-15 07:53:03 +00:00

27 lines
679 B
JavaScript

// Flags: --disable-warning=ExperimentalWarning
'use strict';
// fs.linkSync dispatches to VFS for hard links within the same mount.
require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const vfs = require('node:vfs');
const myVfs = vfs.create();
myVfs.mkdirSync('/src', { recursive: true });
myVfs.writeFileSync('/src/hello.txt', 'hello world');
const mountPoint = myVfs.mount();
fs.linkSync(
path.join(mountPoint, 'src/hello.txt'),
path.join(mountPoint, 'src/hello-link.txt'),
);
assert.strictEqual(
fs.readFileSync(path.join(mountPoint, 'src/hello-link.txt'), 'utf8'),
'hello world',
);
myVfs.unmount();