{"library":"mk-dirs","title":"Recursive Directory Creation Utility","description":"mk-dirs is a minimalistic, Promise-based utility designed for recursively creating directories in Node.js, functioning as an `mkdir -p` equivalent. Currently stable at version 3.0.0, it differentiates itself by being exceptionally lightweight (381B to 419B gzipped) and having zero external dependencies, offering a faster alternative to packages like `mkdirp` and `make-dir`. It provides both an asynchronous (default) and a synchronous opt-in mode, catering to different application needs and Node.js versions (>=8.x for async, >=6.x for sync). While Node.js v10.12.0+ includes native `fs.mkdir` with a `recursive` option, `mk-dirs` maintains its value through a consistent, promise-based API and `cwd` option. Its release cadence is not explicitly stated but typically follows a \"release when needed\" pattern for such focused utilities.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install mk-dirs"],"cli":null},"imports":["import { mkdir } from 'mk-dirs';","const { mkdir } = require('mk-dirs');","import { mkdir } from 'mk-dirs/sync';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { mkdir } from 'mk-dirs';\nimport { resolve } from 'path';\n\nasync function createDirectories() {\n  const baseDir = process.cwd();\n  console.log(`Current working directory: ${baseDir}`);\n\n  // Async/await usage\n  try {\n    let output1 = await mkdir('foo/bar/baz');\n    console.log(`Created directory (async/await): ${output1}`);\n\n    // Using `cwd` option\n    let customCwd = resolve(baseDir, 'temp/custom');\n    let output2 = await mkdir('alpha/beta', { cwd: customCwd });\n    console.log(`Created directory with custom cwd: ${output2}`);\n  } catch (err) {\n    console.error('Error during async/await mkdir:', err);\n  }\n\n  // Promise chain usage\n  mkdir('another/path/deeply')\n    .then(output => {\n      console.log(`Created directory (Promise chain): ${output}`);\n    })\n    .catch(err => {\n      console.error('Error during Promise chain mkdir:', err);\n    });\n}\n\ncreateDirectories();","lang":"typescript","description":"Demonstrates asynchronous recursive directory creation using both async/await and Promise chaining, including the use of a custom `cwd` option.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}