From a530e2d94b07304964241bd16859e8bd37d559f1 Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Wed, 11 Dec 2024 09:46:41 -0800 Subject: [PATCH] fix timing debug log --- packages/plugins/1password/src/cli-helper.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/plugins/1password/src/cli-helper.ts b/packages/plugins/1password/src/cli-helper.ts index 283275ee..4494d5bb 100644 --- a/packages/plugins/1password/src/cli-helper.ts +++ b/packages/plugins/1password/src/cli-helper.ts @@ -38,14 +38,21 @@ async function checkOpCliAuth() { // except for one further trick, which is to first check if we are already logged in, and resolve right away opAuthDeferred = createDeferredPromise(); const startAt = new Date(); + let isLoggedIn: boolean; try { await spawnAsync('op', ['whoami']); - opAuthDeferred.resolve(true); + isLoggedIn = true; } catch (err) { + isLoggedIn = false; + } + + const whoamiTime = +new Date() - +startAt; + debug(`additional whoami check took ${whoamiTime}ms`); + + if (isLoggedIn) { + opAuthDeferred.resolve(true); + } else { return opAuthDeferred.resolve; - } finally { - const whoamiTime = +new Date() - +startAt; - debug(`additional whoami check took ${whoamiTime}ms`); } } }