-import fs from 'fs';
+import fs from 'node:fs';
import { FileType } from '../types/FileType';
import FileUtils from '../utils/FileUtils';
this.FSWatchers.set(
file,
FileUtils.watchJsonFile(
- this.logPrefix(file),
- FileType.Authorization,
file,
- null,
+ FileType.Authorization,
+ this.logPrefix(file),
+ undefined,
(event, filename) => {
- if (filename && event === 'change') {
+ if (Utils.isNotEmptyString(filename) && event === 'change') {
try {
logger.debug(
`${this.logPrefix(file)} ${FileType.Authorization} file have changed, reload`
this.deleteFSWatcher(file);
} catch (error) {
FileUtils.handleFileException(
- this.logPrefix(file),
- FileType.Authorization,
file,
+ FileType.Authorization,
error as NodeJS.ErrnoException,
+ this.logPrefix(file),
{
throwError: false,
}
authorizedTags = JSON.parse(fs.readFileSync(file, 'utf8')) as string[];
} catch (error) {
FileUtils.handleFileException(
- this.logPrefix(file),
- FileType.Authorization,
file,
- error as NodeJS.ErrnoException
+ FileType.Authorization,
+ error as NodeJS.ErrnoException,
+ this.logPrefix(file)
);
}
} else {
return authorizedTags;
}
- private logPrefix(file: string): string {
+ private logPrefix = (file: string): string => {
return Utils.logPrefix(` Authorized tags cache for authorization file '${file}' |`);
- }
+ };
}