mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
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>
27 lines
680 B
JavaScript
27 lines
680 B
JavaScript
// Flags: --disable-warning=ExperimentalWarning
|
|
'use strict';
|
|
|
|
// fs.copyFileSync dispatches to VFS when both paths are 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.copyFileSync(
|
|
path.join(mountPoint, 'src/hello.txt'),
|
|
path.join(mountPoint, 'src/copy.txt'),
|
|
);
|
|
assert.strictEqual(
|
|
fs.readFileSync(path.join(mountPoint, 'src/copy.txt'), 'utf8'),
|
|
'hello world',
|
|
);
|
|
|
|
myVfs.unmount();
|