Skip to content

Commit

Permalink
add try-catch around fs.writeSync
Browse files Browse the repository at this point in the history
  • Loading branch information
olya-r committed Apr 11, 2018
1 parent e116bc1 commit ef0abe6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions util/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,15 @@ module.exports = (function() {
fd = fs.openSync(path, 'w', 438);
}
if (fd) {
fs.writeSync(fd, content, 0, content.length, 0);
fs.closeSync(fd);
try {
fs.writeSync(fd, content, 0, content.length, 0);
}
catch (e){
throw e;
}
finally {
fs.closeSync(fd);
}
}
fs.chmodSync(path, attr || 438);
return true;
Expand Down

0 comments on commit ef0abe6

Please sign in to comment.