Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mk-dirs

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mk-dirs

Make a directory and its parents, if necessary.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9K
decreased by-44.42%
Maintainers
1
Weekly downloads
 
Created
Source

mk-dirs Build Status: OSX & Linux Build Status: Windows

Make a directory and its parents, if necessary.

This is a fast and lightweight alternative to mkdirp. It's also heavily inspired by make-dir.

Check out Comparisons for more info!

Install

$ npm install --save mk-dirs

Usage

$ pwd
/Users/hello/world
$ tree
.
const mkdir = require('mk-dirs');

mkdir('foo/bar/baz').then(path => {
  console.log(path);
  //=> '/Users/hello/world/foo/bar/baz'
});
$ tree
.
└── foo
    └── bar
        └── baz
Multiple Directories
const mkdir = require('mk-dirs');

Promise.all([
  mkdir('cat/cow'),
  mkdir('foo/bar/baz')
]).then(paths => {
  console.log(paths);
  //=> [ '/Users/hello/world/cat/cow', '/Users/hello/world/foo/bar/baz' ]
});

API

mkdir(path, [options])

Returns a Promise, which resolves with the full path of the created directory.

path

Type: string

Directory to create.

options.fs

Type: object
Default: require('fs')

Optionally use a custom fs implementation. For example graceful-fs.

Important: Must include mkdir and stat methods!

options.mode

Type: integer
Default: 0o777 & (~process.umask())

Directory permissions.

Note: Must be in octal format!

Comparisons

make-dir
  • Slightly faster
  • Doesn't re-wrap an existing Promise
  • Doesn't ship with a .sync method
  • Zero dependencies
mkdirp
  • Promise API (Async/await ready!)
  • Fixes many mkdirp issues: #96 #70 #66
  • CI-tested on macOS, Linux, and Windows
  • Doesn't ship with a .sync method
  • Doesn't bundle a CLI

Benchmarks

:bulb: Please consider that these benchmarks are largely affected by System behavior! In other words, the time it takes your OS to create a directory is never consistent.

mk-dirs
  --> 3,768 ops/sec ±1.95% (72 runs sampled)
make-dir
  --> 3,527 ops/sec ±4.28% (64 runs sampled)
mkdirp
  --> 3,305 ops/sec ±2.56% (67 runs sampled)

License

MIT © Luke Edwards

FAQs

Package last updated on 29 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc