diff --git a/lib/appenders/fileSync.js b/lib/appenders/fileSync.js index 763da33..7519de5 100755 --- a/lib/appenders/fileSync.js +++ b/lib/appenders/fileSync.js @@ -6,11 +6,6 @@ const os = require('os'); const eol = os.EOL; function touchFile(file, options) { - // if the file exists, nothing to do - if (fs.existsSync(file)) { - return; - } - // attempt to create the directory const mkdir = (dir) => { try { @@ -45,9 +40,8 @@ function touchFile(file, options) { }; mkdir(path.dirname(file)); - // touch the file to apply flags (like w to truncate the file) - const id = fs.openSync(file, options.flags, options.mode); - fs.closeSync(id); + // try to throw EISDIR, EROFS, EACCES + fs.appendFileSync(file, "", { mode: options.mode, flags: options.flag }); } class RollingFileSync {