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>
30 lines
848 B
JavaScript
30 lines
848 B
JavaScript
// Flags: --disable-warning=ExperimentalWarning
|
|
'use strict';
|
|
|
|
// fs.chmodSync, fs.chownSync, fs.lchownSync, fs.utimesSync, and
|
|
// fs.lutimesSync dispatch to VFS. The MemoryProvider accepts these calls as
|
|
// metadata mutations without throwing.
|
|
|
|
require('../common');
|
|
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 target = path.join(mountPoint, 'src/hello.txt');
|
|
const uid = process.getuid?.() ?? 0;
|
|
const gid = process.getgid?.() ?? 0;
|
|
const now = new Date();
|
|
|
|
fs.chmodSync(target, 0o644);
|
|
fs.chownSync(target, uid, gid);
|
|
fs.lchownSync(target, uid, gid);
|
|
fs.utimesSync(target, now, now);
|
|
fs.lutimesSync(target, now, now);
|
|
|
|
myVfs.unmount();
|