1 | # outputFileSync(file, data, [options])
|
2 |
|
3 | Almost 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
|
12 | const fs = require('fs-extra')
|
13 |
|
14 | const file = '/tmp/this/path/does/not/exist/file.txt'
|
15 | fs.outputFileSync(file, 'hello!')
|
16 |
|
17 | const data = fs.readFileSync(file, 'utf8')
|
18 | console.log(data) // => hello!
|
19 | ```
|