From 3b0f220402e95b7b59ae9e54584fc9ecf61cdada Mon Sep 17 00:00:00 2001 From: Frederik <53608074+N0chteil@users.noreply.github.com> Date: Tue, 6 Jun 2023 21:29:19 +0200 Subject: [PATCH] feat: make checkIfMusicInstalled optional --- src/index.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index d1a7a2e..8db3e44 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,21 +11,32 @@ import EventEmitter from "events"; export class AppleBridge { public emitter = new EventEmitter(); public isMusicInstalled: boolean; + public checkIfInstalled: { + music: boolean; + }; static instance: AppleBridge; - constructor() { + constructor( + checkIfInstalled = { + music: true + } + ) { if (AppleBridge.instance) return AppleBridge.instance; AppleBridge.instance = this; + this.checkIfInstalled = checkIfInstalled; this.init(); } async init() { if (!checkIfMusicRunning()) return setTimeout(() => this.init(), 5000); - this.isMusicInstalled = await checkIfMusicInstalled(); + this.isMusicInstalled = + this.checkIfInstalled?.music ?? true + ? await checkIfMusicInstalled() + : true; if (!this.isMusicInstalled) return;