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>
19 lines
509 B
JavaScript
19 lines
509 B
JavaScript
// Flags: --experimental-vfs
|
|
'use strict';
|
|
|
|
// writeSync in append mode must append, not overwrite.
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const vfs = require('node:vfs');
|
|
|
|
const myVfs = vfs.create();
|
|
myVfs.writeFileSync('/append.txt', 'init');
|
|
|
|
const fd = myVfs.openSync('/append.txt', 'a');
|
|
const buf = Buffer.from(' more');
|
|
myVfs.writeSync(fd, buf, 0, buf.length);
|
|
myVfs.closeSync(fd);
|
|
|
|
const content = myVfs.readFileSync('/append.txt', 'utf8');
|
|
assert.strictEqual(content, 'init more');
|