5.0.0 • Published 11 months ago

make-dir v5.0.0

Weekly downloads
44,654,256
License
MIT
Repository
github
Last release
11 months ago

make-dir

Make a directory and its parents if needed - Think mkdir -p

!TIP You probably want the built-in fsPromises.mkdir('…', {recursive: true}) instead.

Advantages over fsPromises.mkdir('…', {recursive: true})

  • Supports a custom fs implementation.

Advantages over mkdirp

  • Promise API (Async/await ready!)
  • Fixes many mkdirp issues: #96 #70 #66
  • CI-tested on macOS, Linux, and Windows
  • Actively maintained
  • Doesn't bundle a CLI
  • Uses the native fs.mkdir/mkdirSync recursive option in Node.js unless overridden

Install

npm install make-dir

Usage

$ pwd
/Users/sindresorhus/fun
$ tree
.
import {makeDirectory} from 'make-dir';

const path = await makeDirectory('unicorn/rainbow/cake');

console.log(path);
//=> '/Users/sindresorhus/fun/unicorn/rainbow/cake'
$ tree
.
└── unicorn
    └── rainbow
        └── cake

Multiple directories:

import {makeDirectory} from 'make-dir';

const paths = await Promise.all([
	makeDirectory('unicorn/rainbow'),
	makeDirectory('foo/bar')
]);

console.log(paths);
/*
[
	'/Users/sindresorhus/fun/unicorn/rainbow',
	'/Users/sindresorhus/fun/foo/bar'
]
*/

API

makeDirectory(path, options?)

Returns a Promise for the path to the created directory.

makeDirectorySync(path, options?)

Returns the path to the created directory.

path

Type: string

The directory to create.

options

Type: object

mode

Type: integer\ Default: 0o777

The directory permissions.

fs

Type: object\ Default: import fs from 'node:fs'

Use a custom fs implementation. For example graceful-fs.

Using a custom fs implementation will block the use of the native recursive option if fs.mkdir or fs.mkdirSync is not the native function.

Related

istanbul-lib-reportdownloaddecompresslesslernaistanbul-apinycspawn-wrap@lerna/createcaching-transformweb-desktop-helperxcassets@ilchishin/prisma-generator-nestjs-dto@prisma/sdk@homeboxio/dreddarchetype-librarybuy510-jarblakprint-utils-tscaweb-clieasy-select-rnvuedragdropuploadimagespopsmart-common-authreact-native-bluetooth2killi8n-react-native-fast-imagemeen-utilsreactifirepizza-cli_testmangareader-dlsolid-state-deploysolid-state-deplycreate-geosecma-libraryrn-send-smscreate-oval-next-app@yannick243/rw-json-filehttp-transfer-daemon@ymkz/webappgen-clispecify-importsbabel-specify-importsmake-crud@abhishekgautam76/node-star@icanpm/api-master@donmhico/create-wds-block@donmhico/wds-create-blocktypescriptifire@xertz/core@cashremit/cr-streamline-iconstest-lwd-clireact-native-template-rfbaseallconfignetlify-plugin-nextjs@cedx/gulp-smartlingairscanairscan-examplepageres-screenlyreadytest-testcafebb-chatreact-native-esc-pos-sahaab@borisovart/atol-kkt-modulenode_contrast@frxf/frxf@bitexchange-ltd/bitexchange-server-7.5.0-beta.3deneme323112maestro-vsc-extension-plugin@texttree/demo-bsa-reference-rcl@robmayer/create-react-library@piyushmishra/critical@fundefund/funde_ck@ntt_app/react-native-custom-notificationreact-native-custom-text-hwjamesssmooth-discord@foreman/fssharper-shape-utils@iamrokt/todo-cliatdownloaderdiscord-music-botsreact-native-covid-sdkgql_din_modalex-frontend-sdk-stagingreact-initializrafryxiconsreact-native-thanh-toast-library@oopsunome/gitin@thanhnguyen14797/react-native-thanh-toast-library@l1nyanm1ng/react-picture-viewer@saeon/ol-react@saeon/quick-formcthpb-plugin-socialtinbox@olivervorasai/slidermysql-formatreact-native-printer-brothersrn-pdf-reader-offlineritabot@haoadoresorange/gitpkgcbmis-ai-toolboxdex-react-package-creation-1@gadmin2/prisma-generator-nestjsreact-native-shekhar-bridge-testasterjscogoportutils
5.0.0

11 months ago

4.0.0

2 years ago

3.1.0

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

8 years ago