unified

Project:vfile/vfile-mkdirp

Package:vfile-mkdirp@1.0.0

  1. Dependencies:1·Dependents:0
  2. Recursively mkdir, like mkdir -p, for virtual files
  1. text 15
  2. file 14
  3. vfile 13
  4. virtual 12
  5. processing 5

vfile-mkdirp

Build Coverage Downloads Sponsors Backers Chat

Make sure the directory to a vfile exists.

Install

npm:

npm install vfile-mkdirp

Use

var vfile = require('to-vfile')
var mkdirp = require('vfile-mkdirp')

var file = vfile('a/deep/path/to/docs/readme.md')

try {
  await vfile.write(file)
} catch (error) {
  console.log(error)
  // [Error: ENOENT: no such file or directory, open '~/a/deep/path/to/docs/readme.md']
}

await mkdirp(file)
await vfile.write(file)
// Works!

API

mkdirp(file[, mode|options][, callback])

Make sure the directory to the given vfile exists. Passes mode or options through to mkdirp.

If no callback is given, returns a promise that resolves to the given file, or rejects with an error.

Parameters
Returns

Promise or void.

callback(error[, file, made])

Callback called when directories are made.

Parameters

mkdirp.sync(file[, mode|options])

Like mkdirp(file[, mode|options]) but synchronous. Either throws an error or returns the given file.

Contribute

See contributing.md in vfile/.github for ways to get started. See support.md for ways to get help.

This project has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer