MCPcopy Index your code
hub / github.com/nodejs/node / mkdirSync

Function mkdirSync

lib/fs.js:1631–1660  ·  view source on GitHub ↗

* Synchronously creates a directory. * @param {string | Buffer | URL} path * @param {{ * recursive?: boolean; * mode?: string | number; * } | number} [options] * @returns {string | void}

(path, options)

Source from the content-addressed store, hash-verified

1629 * @returns {string | void}
1630 */
1631function mkdirSync(path, options) {
1632 const h = vfsState.handlers;
1633 if (h !== null) {
1634 const vfsResult = h.mkdirSync(path, options);
1635 if (vfsResult !== undefined) return vfsResult.result;
1636 }
1637 let mode = 0o777;
1638 let recursive = false;
1639 if (typeof options === 'number' || typeof options === 'string') {
1640 mode = parseFileMode(options, 'mode');
1641 } else if (options) {
1642 if (options.recursive !== undefined) {
1643 recursive = options.recursive;
1644 validateBoolean(recursive, 'options.recursive');
1645 }
1646 if (options.mode !== undefined) {
1647 mode = parseFileMode(options.mode, 'options.mode');
1648 }
1649 }
1650
1651 const result = binding.mkdir(
1652 getValidatedPath(path),
1653 mode,
1654 recursive,
1655 );
1656
1657 if (recursive) {
1658 return result;
1659 }
1660}
1661
1662/*
1663 * An recursive algorithm for reading the entire contents of the `basePath` directory.

Callers 5

cleanupMethod · 0.50
writeFileMethod · 0.50
createFileAssertMethod · 0.50
copyDirFunction · 0.50
makeTestDirWithFilesFunction · 0.50

Calls 3

parseFileModeFunction · 0.85
mkdirSyncMethod · 0.45
mkdirMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…