mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +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>
30 lines
738 B
JavaScript
30 lines
738 B
JavaScript
// Flags: --disable-warning=ExperimentalWarning
|
|
'use strict';
|
|
|
|
// fs.realpathSync dispatches to VFS and returns a mount-rooted absolute path.
|
|
|
|
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');
|
|
const mountPoint = myVfs.mount();
|
|
|
|
const p = path.join(mountPoint, 'src/hello.txt');
|
|
|
|
// Default string return
|
|
assert.strictEqual(fs.realpathSync(p), p);
|
|
|
|
// Buffer encoding
|
|
{
|
|
const rp = fs.realpathSync(p, { encoding: 'buffer' });
|
|
assert.ok(Buffer.isBuffer(rp));
|
|
assert.strictEqual(rp.toString(), p);
|
|
}
|
|
|
|
myVfs.unmount();
|