repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix(simulator): detect string emptyness properly
[e-mobility-charging-stations-simulator.git]
/
src
/
charging-station
/
AuthorizedTagsCache.ts
diff --git
a/src/charging-station/AuthorizedTagsCache.ts
b/src/charging-station/AuthorizedTagsCache.ts
index 5808f02b57f9a01b6fde9c1d75b281751b68fedd..a3c8e5cdc42c7bfc1f9e978bb59067f856783fd3 100644
(file)
--- 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';
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.FSWatchers.set(
file,
FileUtils.watchJsonFile(
- this.logPrefix(file),
- FileType.Authorization,
file,
file,
- null,
+ FileType.Authorization,
+ this.logPrefix(file),
+ undefined,
(event, filename) => {
(event, filename) => {
- if (
filename
&& event === 'change') {
+ if (
Utils.isNotEmptyString(filename)
&& event === 'change') {
try {
logger.debug(
`${this.logPrefix(file)} ${FileType.Authorization} file have changed, reload`
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.deleteFSWatcher(file);
} catch (error) {
FileUtils.handleFileException(
- this.logPrefix(file),
- FileType.Authorization,
file,
file,
+ FileType.Authorization,
error as NodeJS.ErrnoException,
error as NodeJS.ErrnoException,
+ this.logPrefix(file),
{
throwError: false,
}
{
throwError: false,
}
@@
-94,10
+94,10
@@
export default class AuthorizedTagsCache {
authorizedTags = JSON.parse(fs.readFileSync(file, 'utf8')) as string[];
} catch (error) {
FileUtils.handleFileException(
authorizedTags = JSON.parse(fs.readFileSync(file, 'utf8')) as string[];
} catch (error) {
FileUtils.handleFileException(
- this.logPrefix(file),
- FileType.Authorization,
file,
file,
- error as NodeJS.ErrnoException
+ FileType.Authorization,
+ error as NodeJS.ErrnoException,
+ this.logPrefix(file)
);
}
} else {
);
}
} else {
@@
-106,7
+106,7
@@
export default class AuthorizedTagsCache {
return authorizedTags;
}
return authorizedTags;
}
- private logPrefix
(file: string): string
{
+ private logPrefix
= (file: string): string =>
{
return Utils.logPrefix(` Authorized tags cache for authorization file '${file}' |`);
return Utils.logPrefix(` Authorized tags cache for authorization file '${file}' |`);
- }
+ }
;
}
}