vfile-write

1.0.8 • Public • Published

vfile-write

Travis Coveralls github David

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-write

Usage

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.txt

Api

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

vfile-read

vfile-update

to-vfile

License

MIT © Paul Zimmer

Package Sidebar

Install

npm i vfile-write

Weekly Downloads

1

Version

1.0.8

License

MIT

Unpacked Size

6.16 kB

Total Files

5

Last publish

Collaborators

  • mrzmmr