Skip to content

Commit 6aca05f

Browse files
committed
Fixed JSON parsing error
1 parent b781e0e commit 6aca05f

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/toolchain/swiftly.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,25 @@ import * as vscode from "vscode";
2020
import { Version } from "../utilities/version";
2121
import { z } from "zod";
2222

23-
const ListAvailableResult = z.object({
23+
const ListResult = z.object({
2424
toolchains: z.array(
2525
z.object({
2626
inUse: z.boolean(),
27-
installed: z.boolean(),
2827
isDefault: z.boolean(),
29-
name: z.string(),
3028
version: z.discriminatedUnion("type", [
3129
z.object({
3230
major: z.number(),
3331
minor: z.number(),
3432
patch: z.number().optional(),
33+
name: z.string(),
3534
type: z.literal("stable"),
3635
}),
3736
z.object({
3837
major: z.number(),
3938
minor: z.number(),
4039
branch: z.string(),
4140
date: z.string(),
42-
41+
name: z.string(),
4342
type: z.literal("snapshot"),
4443
}),
4544
]),
@@ -97,9 +96,9 @@ export class Swiftly {
9796
outputChannel?: vscode.OutputChannel
9897
): Promise<string[]> {
9998
try {
100-
const { stdout } = await execFile("swiftly", ["list-available", "--format=json"]);
101-
const response = ListAvailableResult.parse(JSON.parse(stdout));
102-
return response.toolchains.map(t => t.name);
99+
const { stdout } = await execFile("swiftly", ["list", "--format=json"]);
100+
const response = ListResult.parse(JSON.parse(stdout));
101+
return response.toolchains.map(t => t.version.name);
103102
} catch (error) {
104103
outputChannel?.appendLine(`Failed to retrieve Swiftly installations: ${error}`);
105104
throw new Error(

0 commit comments

Comments
 (0)