refactor(adb): encode package verdict certainty in the result type

This commit is contained in:
morluto
2026-10-24 02:24:55 +08:00
parent b31f52946f
commit 75ca7c02ec
2 changed files with 5 additions and 6 deletions
+2 -2
View File
@@ -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(
+3 -4
View File
@@ -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 };