mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
Merge pull request #1252 from log4js-node/feat/tilde-expansion
feat: tilde expansion for filename
This commit is contained in:
commit
f2ddd9fc26
@ -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