* Synchronously creates a directory. * @param {string | Buffer | URL} path * @param {{ * recursive?: boolean; * mode?: string | number; * } | number} [options] * @returns {string | void}
(path, options)
| 1629 | * @returns {string | void} |
| 1630 | */ |
| 1631 | function 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. |
no test coverage detected
searching dependent graphs…