-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathinfo.ts
More file actions
32 lines (29 loc) · 1016 Bytes
/
info.ts
File metadata and controls
32 lines (29 loc) · 1016 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
import { join } from "@std/path/join";
import { getVersions } from "../subcommands/upgrade.ts";
export function getConfigPaths() {
const homeDir = Deno.build.os == "windows"
? Deno.env.get("USERPROFILE")!
: Deno.env.get("HOME")!;
const configDir = join(homeDir, ".deno", "deployctl");
return {
configDir,
updatePath: join(configDir, "update.json"),
credentialsPath: join(configDir, "credentials.json"),
deprecationNoticePath: join(configDir, "deprecation_notice.json"),
};
}
export async function fetchReleases() {
try {
const { latest } = await getVersions();
const updateInfo = { lastFetched: Date.now(), latest };
const { updatePath, configDir } = getConfigPaths();
await Deno.mkdir(configDir, { 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.
}
}