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

Function mkdir

lib/fs.js:1582–1620  ·  view source on GitHub ↗

* Asynchronously creates a directory. * @param {string | Buffer | URL} path * @param {{ * recursive?: boolean; * mode?: string | number; * } | number} [options] * @param {(err?: Error) => any} callback * @returns {void}

(path, options, callback)

Source from the content-addressed store, hash-verified

1580 * @returns {void}
1581 */
1582function mkdir(path, options, callback) {
1583 if (typeof options === 'function') {
1584 callback = options;
1585 options = undefined;
1586 }
1587
1588 const h = vfsState.handlers;
1589 if (h !== null) {
1590 const promise = h.mkdir(path, options);
1591 if (promise !== undefined) {
1592 PromisePrototypeThen(promise, (r) => callback(null, r.result), callback);
1593 return;
1594 }
1595 }
1596
1597 let mode = 0o777;
1598 let recursive = false;
1599 if (typeof options === 'number' || typeof options === 'string') {
1600 mode = parseFileMode(options, 'mode');
1601 } else if (options) {
1602 if (options.recursive !== undefined) {
1603 recursive = options.recursive;
1604 validateBoolean(recursive, 'options.recursive');
1605 }
1606 if (options.mode !== undefined) {
1607 mode = parseFileMode(options.mode, 'options.mode');
1608 }
1609 }
1610 callback = makeCallback(callback);
1611
1612 const req = new FSReqCallback();
1613 req.oncomplete = callback;
1614 binding.mkdir(
1615 getValidatedPath(path),
1616 mode,
1617 recursive,
1618 req,
1619 );
1620}
1621
1622/**
1623 * Synchronously creates a directory.

Callers 3

execWorkspacesMethod · 0.50
editMethod · 0.50
saveSnapshotsMethod · 0.50

Calls 4

parseFileModeFunction · 0.85
makeCallbackFunction · 0.70
callbackFunction · 0.50
mkdirMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…