@@ -5,21 +5,33 @@ export function getConfigPaths() {
55 const homeDir = Deno . build . os == "windows"
66 ? Deno . env . get ( "USERPROFILE" ) !
77 : Deno . env . get ( "HOME" ) ! ;
8- const configDir = join ( homeDir , ".deno" , "deployctl" ) ;
8+ const xdgCacheDir = Deno . env . get ( "XDG_CACHE_HOME" ) ;
9+ const xdgConfigDir = Deno . env . get ( "XDG_CONFIG_HOME" ) ;
10+
11+ const denoDir = Deno . env . get ( "DENO_DIR" ) || join ( homeDir , ".deno" ) ;
12+ const cacheDir = join (
13+ xdgCacheDir ? join ( xdgCacheDir , "deno" ) : denoDir ,
14+ "deployctl" ,
15+ ) ;
16+ const configDir = join (
17+ xdgConfigDir ? join ( xdgConfigDir , "deno" ) : denoDir ,
18+ "deployctl" ,
19+ ) ;
920
1021 return {
22+ cacheDir,
1123 configDir,
12- updatePath : join ( configDir , "update.json" ) ,
13- credentialsPath : join ( configDir , "credentials.json" ) ,
24+ updatePath : join ( cacheDir , "update.json" ) ,
25+ credentialsPath : join ( cacheDir , "credentials.json" ) ,
1426 } ;
1527}
1628
1729export async function fetchReleases ( ) {
1830 try {
1931 const { latest } = await getVersions ( ) ;
2032 const updateInfo = { lastFetched : Date . now ( ) , latest } ;
21- const { updatePath, configDir } = getConfigPaths ( ) ;
22- await Deno . mkdir ( configDir , { recursive : true } ) ;
33+ const { updatePath, cacheDir } = getConfigPaths ( ) ;
34+ await Deno . mkdir ( cacheDir , { recursive : true } ) ;
2335 await Deno . writeFile (
2436 updatePath ,
2537 new TextEncoder ( ) . encode ( JSON . stringify ( updateInfo , null , 2 ) ) ,
0 commit comments