File tree Expand file tree Collapse file tree 1 file changed +22
-10
lines changed Expand file tree Collapse file tree 1 file changed +22
-10
lines changed Original file line number Diff line number Diff line change 1
1
const FALLBACK = "1.98.1"
2
2
3
3
export 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 )
7
8
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
+ )
11
14
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
+ }
15
22
16
- return FALLBACK
23
+ return FALLBACK
24
+ } catch {
25
+ return FALLBACK
26
+ } finally {
27
+ clearTimeout ( timeout )
28
+ }
17
29
}
18
30
19
31
await getVSCodeVersion ( )
You can’t perform that action at this time.
0 commit comments