vfile-mkdirp

vfile utility to make sure the directory of a file exists on the file system

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
vfile-mkdirp
203.0.03 years ago4 years agoMinified + gzip package size for vfile-mkdirp in KB

Readme

vfile-mkdirp
!Buildbuild-badgebuild !Coveragecoverage-badgecoverage !Downloadsdownloads-badgedownloads !Sponsorssponsors-badgecollective !Backersbackers-badgecollective !Chatchat-badgechat
Make sure the directory to a vfilevfile exists.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.
npm install vfile-mkdirp
## Use

```js
import {toVFile as vfile} from 'to-vfile'
import {mkdirp} from '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

This package exports the following identifiers: mkdirp, mkdirpSync. There is no default export.

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

Make sure the directory to the given vfilevfile exists. Passes mode or options through to mkdirpmkdirp.
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])

Callback called when done.
Parameters
  • error (Error) — Error, when failed
  • file (VFilevfile, optional) — Given file, when complete

mkdirpSync(file[, mode|options])

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

Contribute

See contributing.mdcontributing in vfile/.githubhealth for ways to get started. See support.mdsupport for ways to get help.
This project has a code of conductcoc. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MITlicense © Titus Wormerauthor