Safari -> singleton

This commit is contained in:
punkfairie 2023-05-12 00:05:34 -07:00
parent 2174496afb
commit 5c69024c02
2 changed files with 11 additions and 2 deletions

View file

@ -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

View file

@ -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) {