Skip to content

Commit

Permalink
Workaround for npm#28
Browse files Browse the repository at this point in the history
  • Loading branch information
Knagis committed Jan 15, 2018
1 parent 1597785 commit ef98409
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,14 @@ function writeFileSync (filename, data, options) {
fs.closeSync(fd)
if (options.chown) fs.chownSync(tmpfile, options.chown.uid, options.chown.gid)
if (options.mode) fs.chmodSync(tmpfile, options.mode)
fs.renameSync(tmpfile, filename)
try {
fs.renameSync(tmpfile, filename);
} catch (err) {
if (process.platform !== "win32" || err.errno !== -4048 || !fs.existsSync(filename)) {
// workaround for https://github.com/npm/write-file-atomic/issues/28
throw err;
}
}
removeOnExit()
} catch (err) {
removeOnExit()
Expand Down

0 comments on commit ef98409

Please sign in to comment.