Skip to content

risan/create-dir

Repository files navigation

Create Directory Recursively

Build Status Test Covarage Latest Version

Create directory recursively.

It works similar to the mkdir -p. For Node >= 10.12.0, it will use the built-in mkdir recursive option.

Installation

$ npm install create-dir

Usage

const createDir = require("create-dir");

(async () => {
  try {
    await createDir("foo/bar/baz");
  } catch(error) {
    console.error(error.message);
  }
})();

API

createDir(path, [mode])

Parameters

  • path (String): The path directory to create.
  • mode (optional Number): Directory permission, default to 0o777.

Returns

It returns a Promise which when resolved contains a true value.

Related

  • write-to-file: Module to write data to file and automatically create its directories if not exists.

License

MIT © Risan Bagja Pradana