Refine code formatting rules
[e-mobility-charging-stations-simulator.git] / src / charging-station / AuthorizedTagsCache.ts
index 4a9da4ce67f3bfa6e0ca699395f971d1a42712fc..4f853a971fc537fe35f872fbeaf6f2075a50e830 100644 (file)
@@ -1,8 +1,9 @@
+import fs from 'fs';
+
 import { FileType } from '../types/FileType';
 import FileUtils from '../utils/FileUtils';
-import Utils from '../utils/Utils';
-import fs from 'fs';
 import logger from '../utils/Logger';
+import Utils from '../utils/Utils';
 
 export default class AuthorizedTagsCache {
   private static instance: AuthorizedTagsCache | null = null;
@@ -15,17 +16,17 @@ export default class AuthorizedTagsCache {
   }
 
   public static getInstance(): AuthorizedTagsCache {
-    if (!AuthorizedTagsCache.instance) {
+    if (AuthorizedTagsCache.instance === null) {
       AuthorizedTagsCache.instance = new AuthorizedTagsCache();
     }
     return AuthorizedTagsCache.instance;
   }
 
   public getAuthorizedTags(file: string): string[] {
-    if (!this.hasTags(file)) {
+    if (this.hasTags(file) === false) {
       this.setTags(file, this.getAuthorizedTagsFromFile(file));
       // Monitor authorization file
-      !this.FSWatchers.has(file) &&
+      this.FSWatchers.has(file) === false &&
         this.FSWatchers.set(
           file,
           FileUtils.watchJsonFile(
@@ -37,10 +38,7 @@ export default class AuthorizedTagsCache {
               if (filename && event === 'change') {
                 try {
                   logger.debug(
-                    this.logPrefix(file) +
-                      ' ' +
-                      FileType.Authorization +
-                      ' file have changed, reload'
+                    `${this.logPrefix(file)} ${FileType.Authorization} file have changed, reload`
                   );
                   this.deleteTags(file);
                   this.deleteFSWatcher(file);
@@ -63,6 +61,10 @@ export default class AuthorizedTagsCache {
     return this.getTags(file);
   }
 
+  public deleteAuthorizedTags(file: string): boolean {
+    return this.deleteTags(file);
+  }
+
   private hasTags(file: string): boolean {
     return this.tagsCaches.has(file);
   }
@@ -99,7 +101,7 @@ export default class AuthorizedTagsCache {
         );
       }
     } else {
-      logger.info(this.logPrefix(file) + ' No authorization file given)');
+      logger.info(`${this.logPrefix(file)} No authorization file given`);
     }
     return authorizedTags;
   }