mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Adds the node:vfs builtin module with VirtualFileSystem and provider classes. No integration with fs, modules, or SEA. Assisted-by: Claude-Opus4.7 Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/63115 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
25 lines
639 B
JavaScript
25 lines
639 B
JavaScript
// Flags: --experimental-vfs
|
|
'use strict';
|
|
|
|
// Hard-link error cases: creating a link to a directory or to an
|
|
// already-existing path.
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const vfs = require('node:vfs');
|
|
|
|
// Linking to a directory throws EINVAL
|
|
{
|
|
const myVfs = vfs.create();
|
|
myVfs.mkdirSync('/d');
|
|
assert.throws(() => myVfs.linkSync('/d', '/d-link'), { code: 'EINVAL' });
|
|
}
|
|
|
|
// Linking to an existing target throws EEXIST
|
|
{
|
|
const myVfs = vfs.create();
|
|
myVfs.writeFileSync('/a.txt', 'x');
|
|
myVfs.writeFileSync('/b.txt', 'y');
|
|
assert.throws(() => myVfs.linkSync('/a.txt', '/b.txt'), { code: 'EEXIST' });
|
|
}
|