Socket
Socket
Sign inDemoInstall

write-file-atomic

Package Overview
Dependencies
3
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.1 to 1.3.2

24

index.js

@@ -54,5 +54,5 @@ 'use strict'

chain([
[fs, fs.writeFile, tmpfile, data, options.encoding || 'utf8'],
[writeFileAsync, tmpfile, data, options.mode, options.encoding || 'utf8'],
options.chown && [fs, fs.chown, tmpfile, options.chown.uid, options.chown.gid],
options.mode && [fs, fs.chmod, tmpfile, options.mode],
options.chown && [fs, fs.chown, tmpfile, options.chown.uid, options.chown.gid],
[fs, fs.rename, tmpfile, filename]

@@ -64,2 +64,17 @@ ], function (err) {

}
// doing this instead of `fs.writeFile` in order to get the ability to
// call `fsync`.
function writeFileAsync (file, data, mode, encoding, cb) {
fs.open(file, 'w', options.mode, function (err, fd) {
if (err) return cb(err)
fs.write(fd, data, encoding, function (err) {
if (err) return cb(err)
fs.fsync(fd, function (err) {
if (err) return cb(err)
fs.close(fd, cb)
})
})
})
}
}

@@ -94,3 +109,6 @@

fs.writeFileSync(tmpfile, data, options.encoding || 'utf8')
var fd = fs.openSync(tmpfile, 'w', options.mode)
fs.writeSync(fd, data, 0, options.encoding || 'utf8')
fs.fsyncSync(fd)
fs.closeSync(fd)
if (options.chown) fs.chownSync(tmpfile, options.chown.uid, options.chown.gid)

@@ -97,0 +115,0 @@ if (options.mode) fs.chmodSync(tmpfile, options.mode)

2

package.json
{
"name": "write-file-atomic",
"version": "1.3.1",
"version": "1.3.2",
"description": "Write files in an atomic fashion w/configurable ownership",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc