mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
Co-authored-by: James M Snell <jasnell@gmail.com> Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/63653 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: James M Snell <jasnell@gmail.com>
31 lines
867 B
JavaScript
31 lines
867 B
JavaScript
// Flags: --experimental-vfs
|
|
'use strict';
|
|
|
|
// fs.mkdirSync dispatches to VFS, including the `recursive: true` form.
|
|
|
|
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();
|
|
|
|
// Plain mkdir
|
|
fs.mkdirSync(path.join(mountPoint, 'src/d1'));
|
|
assert.strictEqual(
|
|
fs.statSync(path.join(mountPoint, 'src/d1')).isDirectory(), true,
|
|
);
|
|
|
|
// Recursive mkdir creates intermediate directories and returns the first one
|
|
const created = fs.mkdirSync(path.join(mountPoint, 'src/a/b/c'),
|
|
{ recursive: true });
|
|
assert.ok(created !== undefined);
|
|
assert.strictEqual(
|
|
fs.statSync(path.join(mountPoint, 'src/a/b/c')).isDirectory(), true,
|
|
);
|
|
|
|
myVfs.unmount();
|