make-dir
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
semver | 7.6.2 | 93.19 kB | ISC | prod |
Make-dir is a popular npm package that allows users to create a new directory and its parent directories if necessary. This module is particularly beneficial since it resembles the mkdir -p
command in its functionality and offers improvements over the functionality of mkdirp
. Advantages of make-dir include a Promise API that is ready for Async/await, better issue resolution, comprehensive test coverage, compatibility across macOS, Linux, and Windows, proactive maintenance, and absence of bundled CLI. It uses the native fs.mkdir/mkdirSync
recursive option in Node.js version >=10.12.0, barring exceptions.
To use the make-dir npm package, you first need to install it in the project using the npm install make-dir
command. Once installed, it can be imported into your JavaScript file using const makeDir = require('make-dir');
. The makeDir function can be called in an asynchronous function to create directories. For single directory creation the code would look something like this:
const makeDir = require('make-dir');
(async () => {
const path = await makeDir('unicorn/rainbow/cake');
console.log(path);
})();
And for creating multiple directories, the code example:
const makeDir = require('make-dir');
(async () => {
const paths = await Promise.all([
makeDir('unicorn/rainbow'),
makeDir('foo/bar')
]);
console.log(paths);
})();
The aforementioned examples will generate the directories under the given paths.
The detailed make-dir package documentation can be found in the readme file in its GitHub repository. The documentation provides comprehensive information about how to use the package, including its API, installation, and example usage code.