diff --git a/src/models/Safari.ts b/src/models/Safari.ts index 228fcd2..da0e8aa 100644 --- a/src/models/Safari.ts +++ b/src/models/Safari.ts @@ -9,11 +9,12 @@ import { Journal } from "./Journal" import { Log } from "./Log" export class Safari { + static #instance: Safari #journalDir?: string #journalPattern?: string journal?: Journal - constructor(isPackaged: boolean) { + private constructor(isPackaged: boolean) { if (!isPackaged) { // Account for WSL during development this.#journalDir = "/mnt/c/Users/marle/Saved\ Games/Frontier\ Developments/Elite\ Dangerous/" } else if (os.platform() === 'win32') { // Windows @@ -30,6 +31,14 @@ export class Safari { } } + static start(isPackaged: boolean): Safari { + if (!Safari.#instance) { + Safari.#instance = new Safari(isPackaged) + } + + return Safari.#instance + } + /* ------------------------------------------------------------------- #getLatestJournal ---- */ // https://stackoverflow.com/questions/15696218/get-the-most-recent-file-in-a-directory-node-js diff --git a/src/renderer.js b/src/renderer.js index 118e577..5503910 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -46,7 +46,7 @@ window.process.argv.forEach((item) => { /* ------------------------------------------------------------------------------- app setup ---- */ -const safari = new Safari(isPackaged) +const safari = Safari.start(isPackaged) const journal = safari.journal if (!journal) {