1.0.8 • Published 4 years ago

vfile-write v1.0.8

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

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

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago