From 43d8af6cabcc7a972012e12da2bed9c622eace55 Mon Sep 17 00:00:00 2001 From: Long Zhao Date: Mon, 12 Aug 2024 23:14:40 +1000 Subject: [PATCH] fix: fix fn has been called twice --- src/CGDGarageDoor.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/CGDGarageDoor.ts b/src/CGDGarageDoor.ts index e01ea73..5a0d515 100644 --- a/src/CGDGarageDoor.ts +++ b/src/CGDGarageDoor.ts @@ -92,7 +92,7 @@ export class CGDGarageDoor { softValue?: string; until?: () => Promise; }): Promise => { - const fn = async () => { + const fn = () => { this.log.debug(`Setting ${cmd} to ${softValue}`); let oldStatus: Status; @@ -152,18 +152,13 @@ export class CGDGarageDoor { } }, }); - - return result; }; - let result: unknown; if (until) { - result = await this.withRunQ(cmd, fn); + return this.withRunQ(cmd, fn); } - result = await fn(); - - return result; + return fn(); }; private withIsUpdating = async (fn: () => Promise): Promise => {