From 745005c4c37bdb4b502b770c5369701d9de8da52 Mon Sep 17 00:00:00 2001 From: CodeHz Date: Fri, 20 Mar 2020 16:10:54 +0800 Subject: [PATCH] fix fetch --- src/versions.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/versions.ts b/src/versions.ts index 20cddd5..44c5be4 100644 --- a/src/versions.ts +++ b/src/versions.ts @@ -16,9 +16,8 @@ type TagItem = { }; export async function fetchVersions() { - const tags: [TagItem] = await (await fetch( - "https://api.github.com/repos/xmake-io/xmake/git/refs/tags" - )).json(); + const file = await downloadTool("https://api.github.com/repos/xmake-io/xmake/git/refs/tags"); + const tags: [TagItem] = JSON.parse(await fs.readFile(file, { encoding: "utf-8" })); return tags.map(({ ref, object: {sha} }) => [ref.slice(11), sha]).reduce( (o, [k, v]) => { o[k] = v;