Make sure the directory to a vfile
exists.
This package is ESM only:
Node 12+ is needed to use it and it must be import
ed instead of require
d.
npm:
npm install vfile-mkdirp
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!
This package exports the following identifiers: mkdirp
, mkdirpSync
.
There is no default export.
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.
file
(VFile
) — Virtual filemode
(string
, optional) — Passed tomkdirp
options
(Object
, optional) — Passed tomkdirp
callback
(Function
, optional)
Promise or void.
Callback called when done.
error
(Error
) — Error, when failedfile
(VFile
, optional) — Given file, when complete
Like mkdirp(file[, mode|options])
but synchronous.
Either throws an error or returns the given file.
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, organization, or community you agree to abide by its terms.