write-file-atomic
Advanced tools
Comparing version 2.4.0 to 2.4.1
@@ -0,1 +1,5 @@ | ||
# 2.4.1 | ||
* Fix a bug where `signal-exit` instances would be leaked. This was fixed when addressing #35. | ||
# 2.4.0 | ||
@@ -2,0 +6,0 @@ |
17
index.js
@@ -61,3 +61,4 @@ 'use strict' | ||
var tmpfile | ||
var removeOnExit = cleanupOnExit(() => tmpfile) | ||
/* istanbul ignore next -- The closure only gets called when onExit triggers */ | ||
var removeOnExitHandler = onExit(cleanupOnExit(() => tmpfile)) | ||
var absoluteName = path.resolve(filename) | ||
@@ -158,5 +159,6 @@ | ||
}).then(function success () { | ||
removeOnExitHandler() | ||
callback() | ||
}).catch(function fail (err) { | ||
removeOnExit() | ||
}, function fail (err) { | ||
removeOnExitHandler() | ||
fs.unlink(tmpfile, function () { | ||
@@ -201,3 +203,4 @@ callback(err) | ||
var removeOnExit = onExit(cleanupOnExit(tmpfile)) | ||
var cleanup = cleanupOnExit(tmpfile) | ||
var removeOnExitHandler = onExit(cleanup) | ||
var fd = fs.openSync(tmpfile, 'w', options.mode) | ||
@@ -216,8 +219,8 @@ if (Buffer.isBuffer(data)) { | ||
fs.renameSync(tmpfile, filename) | ||
removeOnExit() | ||
removeOnExitHandler() | ||
} catch (err) { | ||
removeOnExit() | ||
try { fs.unlinkSync(tmpfile) } catch (e) {} | ||
removeOnExitHandler() | ||
cleanup() | ||
throw err | ||
} | ||
} |
{ | ||
"name": "write-file-atomic", | ||
"version": "2.4.0", | ||
"version": "2.4.1", | ||
"description": "Write files in an atomic fashion w/configurable ownership", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11535
209