-
-
Notifications
You must be signed in to change notification settings - Fork 636
Expand file tree
/
Copy pathget-vscode-version.ts
More file actions
33 lines (27 loc) · 678 Bytes
/
get-vscode-version.ts
File metadata and controls
33 lines (27 loc) · 678 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
const FALLBACK = "1.104.3"
export async function getVSCodeVersion() {
const controller = new AbortController()
const timeout = setTimeout(() => {
controller.abort()
}, 5000)
try {
const response = await fetch(
"https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=visual-studio-code-bin",
{
signal: controller.signal,
},
)
const pkgbuild = await response.text()
const pkgverRegex = /pkgver=([0-9.]+)/
const match = pkgbuild.match(pkgverRegex)
if (match) {
return match[1]
}
return FALLBACK
} catch {
return FALLBACK
} finally {
clearTimeout(timeout)
}
}
await getVSCodeVersion()