Files
node/test/parallel/test-vfs-fs-chmod-callback.js
Matteo Collina 49ad95045a vfs: unflag
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>
2026-10-15 07:53:03 +00:00

33 lines
960 B
JavaScript

// Flags: --disable-warning=ExperimentalWarning
'use strict';
// fs.chmod, fs.chown, fs.lchown, fs.utimes, and fs.lutimes callbacks dispatch
// through VFS.
const common = 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.chmod(target, 0o644, common.mustSucceed(() => {
fs.chown(target, uid, gid, common.mustSucceed(() => {
fs.lchown(target, uid, gid, common.mustSucceed(() => {
fs.utimes(target, now, now, common.mustSucceed(() => {
fs.lutimes(target, now, now, common.mustSucceed(() => {
myVfs.unmount();
}));
}));
}));
}));
}));