Promisified version of write-file-atomic
npm install write-file-atomically


Promisified version of write-file-atomic:
> an extension for node's fs.writeFile that makes its operation atomic and allows you set ownership (uid/gid of the file)
``javascript
const {readFileSync} = require('fs');
const writeFileAtomically = require('write-file-atomically');
(async () => {
await writeFileAtomically('file.txt', 'Hi!');
readFileSync('file.txt', 'utf8'); //=> 'Hi!'
})();
`
``
npm install write-file-atomically
`javascript`
const writeFileAtomically = require('write-file-atomically');
filename: string, Buffer or URL (a file path where the file to be written) string
data: or Buffer (file contents) Object
options: or string (directly used as write-file-atomic options) Promise
Return:
It asynchronously writes data to the given file path in an atomic manner:
> The file is initially named filename + "." + murmurhex(__filename, process.pid, ++invocations)`. If writeFile completes successfully then, if passed the chown option it will change the ownership of the file. Finally it renames the file back to the filename you specified.
ISC License © 2018 Shinnosuke Watanabe