From 75ca7c02ec40c5d64cc43de45b36e35269ad3990 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Sat, 24 Oct 2026 02:24:55 +0800 Subject: [PATCH] refactor(adb): encode package verdict certainty in the result type --- src/adb/AdbProvider.ts | 4 ++-- src/adb/AdbShellOutput.ts | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/adb/AdbProvider.ts b/src/adb/AdbProvider.ts index cfc0c9feae..dcabe8b5ca 100644 --- a/src/adb/AdbProvider.ts +++ b/src/adb/AdbProvider.ts @@ -2693,7 +2693,7 @@ export class AdbProvider { new AnalysisUnsupportedTargetError( operation, input.serial, - verdict.reason ?? "the device refused the installation", + verdict.reason, ), ); return ok( @@ -2767,7 +2767,7 @@ export class AdbProvider { new AnalysisUnsupportedTargetError( operation, input.serial, - verdict.reason ?? "the device refused the removal", + verdict.reason, ), ); return ok( diff --git a/src/adb/AdbShellOutput.ts b/src/adb/AdbShellOutput.ts index 8e43b82e51..f6fc9e01df 100644 --- a/src/adb/AdbShellOutput.ts +++ b/src/adb/AdbShellOutput.ts @@ -418,10 +418,9 @@ export const packageChangeFailureReason = (output: string): string | null => */ export const parsePackageChangeOutput = ( stdout: string, -): { - readonly status: "success" | "failure" | "unknown"; - readonly reason: string | null; -} => { +): + | { readonly status: "success" | "unknown"; readonly reason: null } + | { readonly status: "failure"; readonly reason: string } => { const text = stdout.trim(); const failure = packageChangeFailureReason(text); if (failure !== null) return { status: "failure", reason: failure };