File tree Expand file tree Collapse file tree 4 files changed +24
-10
lines changed Expand file tree Collapse file tree 4 files changed +24
-10
lines changed Original file line number Diff line number Diff line change 2
2
"name" : " python-dependencies-vscode" ,
3
3
"displayName" : " Python Dependencies" ,
4
4
"description" : " Utilities for managing Python dependencies" ,
5
- "version" : " 0.0.16 " ,
5
+ "version" : " 0.0.17 " ,
6
6
"publisher" : " patrick91" ,
7
7
"engines" : {
8
8
"vscode" : " ^1.53.0"
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ const getCacheKey = (library: string) => `${CACHE_PREFIX}-${library}`;
8
8
9
9
export const getInfo = async (
10
10
library : string ,
11
- ) : Promise < { version : string ; summary : string } > => {
11
+ ) : Promise < { version : string ; summary : string } | null > => {
12
12
const cache = getCache ( ) ;
13
13
const key = getCacheKey ( library ) ;
14
14
@@ -27,12 +27,16 @@ export const getInfo = async (
27
27
28
28
const data = await fetchLibrary ( library ) ;
29
29
30
- info = {
31
- version : data . info . version as string ,
32
- summary : data . info . summary as string ,
33
- } ;
30
+ if ( data ) {
31
+ info = {
32
+ version : data . info . version as string ,
33
+ summary : data . info . summary as string ,
34
+ } ;
34
35
35
- await cache . put ( key , JSON . stringify ( { info, date : new Date ( ) } ) ) ;
36
+ await cache . put ( key , JSON . stringify ( { info, date : new Date ( ) } ) ) ;
36
37
37
- return info ;
38
+ return info ;
39
+ }
40
+
41
+ return null ;
38
42
} ;
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ const updateVersions = (
17
17
deps . map ( async ( dep ) => {
18
18
const info = await getInfo ( dep . name ) ;
19
19
20
+ if ( ! info ) {
21
+ return ;
22
+ }
23
+
20
24
dep . version . installed = installedVersions [ dep . name ] ;
21
25
dep . version . latest = info . version ;
22
26
dep . summary = info . summary ;
Original file line number Diff line number Diff line change 1
1
import fetch from "node-fetch" ;
2
2
3
3
export const fetchLibrary = async ( library : string ) => {
4
- const x = await fetch ( `https://pypi.org/pypi/${ library } /json` ) ;
4
+ const response = await fetch ( `https://pypi.org/pypi/${ library } /json` ) ;
5
5
6
- return await x . json ( ) ;
6
+ if ( response . status === 200 ) {
7
+ return await response . json ( ) ;
8
+ }
9
+
10
+ console . log ( `unable to fetch library ${ library } ` ) ;
11
+
12
+ return null ;
7
13
} ;
You can’t perform that action at this time.
0 commit comments