vfile-write
v1.0.8
Published
Write vfile to file
Downloads
9
Readme
vfile-write
Writes a VFile and any vfiles nested in its contents. Write will also create any directories needed as well as the file. Returns a promise or callback.
Install
npm i -S vfile-writeUsage
The following script:
var write = require('./lib')
var vfile = require('vfile')
var file = vfile({
path: 'one',
contents: [
vfile({
path: 'one.txt',
contents: 'one'
}),
vfile({
path: 'two',
contents: [
vfile({
path: 'two.txt',
contents: 'two'
})
]
})
]
})
write(file, 'utf-8').catch(console.error)Will create the file structure:
one
├── one.txt
└── two
└── two.txtApi
write(file[, options[, callback]])
file
VFile
VFile to write.
options?
object
Options to pass to writeFile and/or mkdir.
callback?
function
Optional callback function. callback(error, files)
returns a promise or callback.
write#sync(file[, options])
Synchronous version of write.
Related
License
MIT © Paul Zimmer
