File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11const FALLBACK = "1.98.1"
22
33export async function getVSCodeVersion ( ) {
4- const response = await fetch (
5- "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=visual-studio-code-bin" ,
6- )
4+ const controller = new AbortController ( )
5+ const timeout = setTimeout ( ( ) => {
6+ controller . abort ( )
7+ } , 5000 )
78
8- const pkgbuild = await response . text ( )
9- const pkgverRegex = / p k g v e r = ( [ 0 - 9 . ] + ) /
10- const match = pkgbuild . match ( pkgverRegex )
9+ try {
10+ const response = await fetch (
11+ "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=visual-studio-code-bin" ,
12+ { signal : controller . signal } ,
13+ )
1114
12- if ( match ) {
13- return match [ 1 ]
14- }
15+ const pkgbuild = await response . text ( )
16+ const pkgverRegex = / p k g v e r = ( [ 0 - 9 . ] + ) /
17+ const match = pkgbuild . match ( pkgverRegex )
18+
19+ if ( match ) {
20+ return match [ 1 ]
21+ }
1522
16- return FALLBACK
23+ return FALLBACK
24+ } catch {
25+ return FALLBACK
26+ } finally {
27+ clearTimeout ( timeout )
28+ }
1729}
1830
1931await getVSCodeVersion ( )
You can’t perform that action at this time.
0 commit comments