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 22 "name" : " python-dependencies-vscode" ,
33 "displayName" : " Python Dependencies" ,
44 "description" : " Utilities for managing Python dependencies" ,
5- "version" : " 0.0.16 " ,
5+ "version" : " 0.0.17 " ,
66 "publisher" : " patrick91" ,
77 "engines" : {
88 "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}`;
88
99export const getInfo = async (
1010 library : string ,
11- ) : Promise < { version : string ; summary : string } > => {
11+ ) : Promise < { version : string ; summary : string } | null > => {
1212 const cache = getCache ( ) ;
1313 const key = getCacheKey ( library ) ;
1414
@@ -27,12 +27,16 @@ export const getInfo = async (
2727
2828 const data = await fetchLibrary ( library ) ;
2929
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+ } ;
3435
35- await cache . put ( key , JSON . stringify ( { info, date : new Date ( ) } ) ) ;
36+ await cache . put ( key , JSON . stringify ( { info, date : new Date ( ) } ) ) ;
3637
37- return info ;
38+ return info ;
39+ }
40+
41+ return null ;
3842} ;
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ const updateVersions = (
1717 deps . map ( async ( dep ) => {
1818 const info = await getInfo ( dep . name ) ;
1919
20+ if ( ! info ) {
21+ return ;
22+ }
23+
2024 dep . version . installed = installedVersions [ dep . name ] ;
2125 dep . version . latest = info . version ;
2226 dep . summary = info . summary ;
Original file line number Diff line number Diff line change 11import fetch from "node-fetch" ;
22
33export 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` ) ;
55
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 ;
713} ;
You can’t perform that action at this time.
0 commit comments