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>
34 lines
827 B
JavaScript
34 lines
827 B
JavaScript
// Flags: --disable-warning=ExperimentalWarning
|
|
'use strict';
|
|
|
|
// fs.mkdtempSync dispatches to VFS and returns a mount-rooted path, including
|
|
// the buffer-encoding variant.
|
|
|
|
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 });
|
|
const mountPoint = myVfs.mount();
|
|
|
|
const prefix = path.join(mountPoint, 'src/tmp-');
|
|
|
|
// String result
|
|
{
|
|
const dir = fs.mkdtempSync(prefix);
|
|
assert.ok(dir.startsWith(prefix));
|
|
assert.strictEqual(dir.length, prefix.length + 6);
|
|
assert.strictEqual(fs.statSync(dir).isDirectory(), true);
|
|
}
|
|
|
|
// Buffer result
|
|
{
|
|
const dir = fs.mkdtempSync(prefix, { encoding: 'buffer' });
|
|
assert.ok(Buffer.isBuffer(dir));
|
|
}
|
|
|
|
myVfs.unmount();
|