Safari -> singleton
This commit is contained in:
parent
2174496afb
commit
5c69024c02
2 changed files with 11 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue