-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathinfo.ts
More file actions
33 lines (30 loc) · 923 Bytes
/
info.ts
File metadata and controls
33 lines (30 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { join } from "@std/path/join";
import { getVersions } from "../subcommands/upgrade.ts";
import { DenoDir } from "@deno/cache-dir";
export function getCachePaths() {
const denoCacheDir = new DenoDir().root;
const cacheDir = join(
denoCacheDir,
"deployctl",
);
return {
cacheDir,
updatePath: join(cacheDir, "update.json"),
credentialsPath: join(cacheDir, "credentials.json"),
};
}
export async function fetchReleases() {
try {
const { latest } = await getVersions();
const updateInfo = { lastFetched: Date.now(), latest };
const { updatePath, cacheDir } = getCachePaths();
await Deno.mkdir(cacheDir, { recursive: true });
await Deno.writeFile(
updatePath,
new TextEncoder().encode(JSON.stringify(updateInfo, null, 2)),
);
} catch (_) {
// We will try again later when the fetch isn't successful,
// so we shouldn't report errors.
}
}