X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FAuthorizedTagsCache.ts;h=a3c8e5cdc42c7bfc1f9e978bb59067f856783fd3;hb=5a2a53cfa256a32aa342d4dee48492118065e84a;hp=5808f02b57f9a01b6fde9c1d75b281751b68fedd;hpb=1895299db899eb53db7fb1615b82624f806017e8;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/AuthorizedTagsCache.ts b/src/charging-station/AuthorizedTagsCache.ts index 5808f02b..a3c8e5cd 100644 --- a/src/charging-station/AuthorizedTagsCache.ts +++ b/src/charging-station/AuthorizedTagsCache.ts @@ -1,4 +1,4 @@ -import fs from 'fs'; +import fs from 'node:fs'; import { FileType } from '../types/FileType'; import FileUtils from '../utils/FileUtils'; @@ -30,12 +30,12 @@ export default class AuthorizedTagsCache { 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` @@ -44,10 +44,10 @@ export default class AuthorizedTagsCache { this.deleteFSWatcher(file); } catch (error) { FileUtils.handleFileException( - this.logPrefix(file), - FileType.Authorization, file, + FileType.Authorization, error as NodeJS.ErrnoException, + this.logPrefix(file), { throwError: false, } @@ -94,10 +94,10 @@ export default class AuthorizedTagsCache { 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 { @@ -106,7 +106,7 @@ export default class AuthorizedTagsCache { return authorizedTags; } - private logPrefix(file: string): string { + private logPrefix = (file: string): string => { return Utils.logPrefix(` Authorized tags cache for authorization file '${file}' |`); - } + }; }