fix(simulator): detect string emptyness properly
[e-mobility-charging-stations-simulator.git] / src / charging-station / AuthorizedTagsCache.ts
index 8c95660d07130155f495ec3d1fa7d017dbab1ca6..a3c8e5cdc42c7bfc1f9e978bb59067f856783fd3 100644 (file)
@@ -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 (!Utils.isEmptyString(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}' |`);
-  }
+  };
 }