Skip to content

Commit

Permalink
feat: include details of missing metadata in hook output
Browse files Browse the repository at this point in the history
  • Loading branch information
zimeg committed Mar 22, 2024
1 parent c5c167c commit 30ce796
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ const getHostedDenoRuntimeVersion = async (): Promise<RuntimeDetails> => {
const metadata = await response.json();
const version = metadata?.["deno-runtime"]?.releases[0]?.version;
if (!version) {
throw new Error("Failed to find the minimum Deno version");
const details = JSON.stringify(metadata, null, " ");
return {
message: `Upstream CLI metadata response included:\n${details}`,
error: {
message: "Failed to find the minimum Deno version",
},
};
}
const message = Deno.version.deno !== version
? `Applications deployed to Slack use Deno version ${version}`
Expand Down
8 changes: 7 additions & 1 deletion src/tests/doctor_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,11 @@ Deno.test("doctor hook tests", async (t) => {
});

await t.step("missing minimums from cli metadata are noted", async () => {
const metadata = {
runtimes: ["deno", "node"],
};
mockFetch.mock("GET@/slackcli/metadata.json", (_req: Request) => {
return new Response(JSON.stringify({}));
return new Response(JSON.stringify(metadata));
});
Deno.version.deno = "1.2.3";

Expand All @@ -137,6 +140,9 @@ Deno.test("doctor hook tests", async (t) => {
{
name: "deno",
current: "1.2.3",
message: `Upstream CLI metadata response included:\n${
JSON.stringify(metadata, null, 2)
}`,
error: {
message: "Failed to find the minimum Deno version",
},
Expand Down

0 comments on commit 30ce796

Please sign in to comment.