From 153cdf4bb08043d67debfa29c8864b32a1205e33 Mon Sep 17 00:00:00 2001 From: Scott Lowe Date: Thu, 30 Apr 2020 10:02:22 +0200 Subject: [PATCH] Refactor: use checkLoggedIn() instead of exitIfNotLoggedIn() Change-type: patch Signed-off-by: Scott Lowe --- lib/actions/logs.ts | 4 ++-- lib/utils/patterns.ts | 16 ---------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/lib/actions/logs.ts b/lib/actions/logs.ts index 4e4bc4ef..52abc2d6 100644 --- a/lib/actions/logs.ts +++ b/lib/actions/logs.ts @@ -91,7 +91,7 @@ export const logs: CommandDefinition< '../utils/device/logs' ); const { validateIPAddress } = await import('../utils/validation'); - const { exitIfNotLoggedIn, exitWithExpectedError } = await import( + const { checkLoggedIn, exitWithExpectedError } = await import( '../utils/patterns' ); const Logger = await import('../utils/logger'); @@ -152,7 +152,7 @@ export const logs: CommandDefinition< servicesToDisplay, ); } else { - await exitIfNotLoggedIn(); + await checkLoggedIn(); if (options.tail) { return balena.logs .subscribe(params.uuidOrDevice, { count: 100 }) diff --git a/lib/utils/patterns.ts b/lib/utils/patterns.ts index 5b8706c4..3896082f 100644 --- a/lib/utils/patterns.ts +++ b/lib/utils/patterns.ts @@ -88,22 +88,6 @@ export async function checkLoggedIn(): Promise { } } -/** - * Check if logged in, and call `exitWithExpectedError()` if not. - * DEPRECATED: Use checkLoggedIn() instead. - */ -export async function exitIfNotLoggedIn(): Promise { - try { - await checkLoggedIn(); - } catch (error) { - if (error instanceof NotLoggedInError) { - exitWithExpectedError(error); - } else { - throw error; - } - } -} - export function askLoginType() { return getForm().ask<'web' | 'credentials' | 'token' | 'register'>({ message: 'How would you like to login?',