mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
feat: tilde expansion for filename
This commit is contained in:
parent
e378b5bda4
commit
a0eceefed1
@ -31,6 +31,10 @@ function fileAppender(file, layout, logSize, numBackups, options, timezoneOffset
|
||||
throw new Error(`Invalid filename: ${file}`);
|
||||
} else if (file.endsWith(path.sep)) {
|
||||
throw new Error(`Filename is a directory: ${file}`);
|
||||
} else {
|
||||
// handle ~ expansion: https://github.com/nodejs/node/issues/684
|
||||
// exclude ~ and ~filename as these can be valid files
|
||||
file = file.replace(new RegExp(`^~(?=${path.sep}.+)`), os.homedir());
|
||||
}
|
||||
file = path.normalize(file);
|
||||
numBackups = (!numBackups && numBackups !== 0) ? 5 : numBackups;
|
||||
|
||||
@ -166,6 +166,10 @@ function fileAppender(file, layout, logSize, numBackups, options, timezoneOffset
|
||||
throw new Error(`Invalid filename: ${file}`);
|
||||
} else if (file.endsWith(path.sep)) {
|
||||
throw new Error(`Filename is a directory: ${file}`);
|
||||
} else {
|
||||
// handle ~ expansion: https://github.com/nodejs/node/issues/684
|
||||
// exclude ~ and ~filename as these can be valid files
|
||||
file = file.replace(new RegExp(`^~(?=${path.sep}.+)`), os.homedir());
|
||||
}
|
||||
file = path.normalize(file);
|
||||
numBackups = (!numBackups && numBackups !== 0) ? 5 : numBackups;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user