mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
refactor: code flow and readability
This commit is contained in:
parent
505204addc
commit
6de1da298e
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user