UNPKG

729 BMarkdownView Raw
1# outputFileSync(file, data, [options])
2
3Almost the same as `writeFileSync` (i.e. it [overwrites](http://pages.citebite.com/v2o5n8l2f5reb)), 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). `options` are what you'd pass to [`fs.writeFileSync()`](https://nodejs.org/api/fs.html#fs_fs_writefilesync_file_data_options).
4
5- `file` `<String>`
6- `data` `<String> | <Buffer> | <Uint8Array>`
7- `options` `<Object> | <String>`
8
9## Example:
10
11```js
12const fs = require('fs-extra')
13
14const file = '/tmp/this/path/does/not/exist/file.txt'
15fs.outputFileSync(file, 'hello!')
16
17const data = fs.readFileSync(file, 'utf8')
18console.log(data) // => hello!
19```