node-fs-extra/docs/outputFile-sync.md
Mani Maghsoudlou b0eb751a75
Improve docs (#795)
* improve docs

* Update docs/ensureSymlink-sync.md

Co-authored-by: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com>

* Update docs/ensureSymlink.md

Co-authored-by: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com>

* add Error type to docs

Co-authored-by: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com>
2020-05-11 16:40:39 -04:00

717 B

outputFileSync(file, data[, options])

Almost the same as writeFileSync (i.e. it overwrites), except that if the parent directory does not exist, it's created. file must be a file path (a buffer or a file descriptor is not allowed).

Example:

const fs = require('fs-extra')

const file = '/tmp/this/path/does/not/exist/file.txt'
fs.outputFileSync(file, 'hello!')

const data = fs.readFileSync(file, 'utf8')
console.log(data) // => hello!