finki-main
main
|
Last change
on this file since 81bc7da was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago |
|
Initial commit
|
-
Property mode
set to
100644
|
|
File size:
507 bytes
|
| Line | |
|---|
| 1 | const fs = require('./fs.js')
|
|---|
| 2 | const getOptions = require('./common/get-options.js')
|
|---|
| 3 | const owner = require('./common/owner.js')
|
|---|
| 4 |
|
|---|
| 5 | const writeFile = async (file, data, opts) => {
|
|---|
| 6 | const options = getOptions(opts, {
|
|---|
| 7 | copy: ['encoding', 'mode', 'flag', 'signal', 'owner'],
|
|---|
| 8 | wrap: 'encoding',
|
|---|
| 9 | })
|
|---|
| 10 | const { uid, gid } = await owner.validate(file, options.owner)
|
|---|
| 11 |
|
|---|
| 12 | const result = await fs.writeFile(file, data, options)
|
|---|
| 13 |
|
|---|
| 14 | await owner.update(file, uid, gid)
|
|---|
| 15 |
|
|---|
| 16 | return result
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | module.exports = writeFile
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.