@@ -15,7 +15,7 @@ export type CacheConfig = Omit<InstallConfig, 'cache'>;
1515 * @see https://github.com/actions/toolkit/issues/47
1616 */
1717export async function fromLocalCache ( config : CacheConfig ) : Promise < string | undefined > {
18- return toolCache . find ( config . package , config . version ) ;
18+ return toolCache . find ( config . package , config . version ) ;
1919}
2020
2121/**
@@ -25,52 +25,52 @@ export async function fromLocalCache(config: CacheConfig): Promise<string | unde
2525 * @see https://github.com/actions/toolkit/issues/47
2626 */
2727export async function toLocalCache ( root : string , config : CacheConfig ) : Promise < string > {
28- return toolCache . cacheDir ( root , config . package , config . version ) ;
28+ return toolCache . cacheDir ( root , config . package , config . version ) ;
2929}
3030
3131/**
3232 * Download the remotely stored `expo-cli` from cache, if any.
3333 * Note, this cache is shared between jobs.
3434 */
3535export async function fromRemoteCache ( config : CacheConfig ) : Promise < string | undefined > {
36- // see: https://github.com/actions/toolkit/blob/8a4134761f09d0d97fb15f297705fd8644fef920/packages/tool-cache/src/tool-cache.ts#L401
37- const target = path . join ( process . env [ 'RUNNER_TOOL_CACHE' ] || '' , config . package , config . version , os . arch ( ) ) ;
38- const cacheKey = config . cacheKey || getRemoteKey ( config ) ;
36+ // see: https://github.com/actions/toolkit/blob/8a4134761f09d0d97fb15f297705fd8644fef920/packages/tool-cache/src/tool-cache.ts#L401
37+ const target = path . join ( process . env [ 'RUNNER_TOOL_CACHE' ] || '' , config . package , config . version , os . arch ( ) ) ;
38+ const cacheKey = config . cacheKey || getRemoteKey ( config ) ;
3939
40- try {
41- // When running with nektos/act, or other custom environments, the cache might not be set up.
42- const hit = await restoreCache ( [ target ] , cacheKey ) ;
43- if ( hit ) {
44- return target ;
45- }
46- } catch ( error ) {
47- if ( ! handleRemoteCacheError ( error ) ) {
48- throw error ;
49- }
50- }
40+ try {
41+ // When running with nektos/act, or other custom environments, the cache might not be set up.
42+ const hit = await restoreCache ( [ target ] , cacheKey ) ;
43+ if ( hit ) {
44+ return target ;
45+ }
46+ } catch ( error ) {
47+ if ( ! handleRemoteCacheError ( error ) ) {
48+ throw error ;
49+ }
50+ }
5151}
5252
5353/**
5454 * Store the root of `expo-cli` in the remote cache, for future reuse.
5555 * Note, this cache is shared between jobs.
5656 */
5757export async function toRemoteCache ( source : string , config : CacheConfig ) : Promise < void > {
58- const cacheKey = config . cacheKey || getRemoteKey ( config ) ;
58+ const cacheKey = config . cacheKey || getRemoteKey ( config ) ;
5959
60- try {
61- await saveCache ( [ source ] , cacheKey ) ;
62- } catch ( error ) {
63- if ( ! handleRemoteCacheError ( error ) ) {
64- throw error ;
65- }
66- }
60+ try {
61+ await saveCache ( [ source ] , cacheKey ) ;
62+ } catch ( error ) {
63+ if ( ! handleRemoteCacheError ( error ) ) {
64+ throw error ;
65+ }
66+ }
6767}
6868
6969/**
7070 * Get the cache key to use when (re)storing the Expo CLI from remote cache.
7171 */
7272function getRemoteKey ( config : Omit < CacheConfig , 'cacheKey' > ) : string {
73- return `${ config . package } -${ process . platform } -${ os . arch ( ) } -${ config . packager } -${ config . version } ` ;
73+ return `${ config . package } -${ process . platform } -${ os . arch ( ) } -${ config . packager } -${ config . version } ` ;
7474}
7575
7676/**
@@ -81,14 +81,14 @@ function getRemoteKey(config: Omit<CacheConfig, 'cacheKey'>): string {
8181 * @returns If the error was handled properly.
8282 */
8383function handleRemoteCacheError ( error : Error ) : boolean {
84- const isReserveCacheError = error instanceof ReserveCacheError ;
85- const isCacheUnavailable = error . message . toLowerCase ( ) . includes ( 'cache service url not found' ) ;
84+ const isReserveCacheError = error instanceof ReserveCacheError ;
85+ const isCacheUnavailable = error . message . toLowerCase ( ) . includes ( 'cache service url not found' ) ;
8686
87- if ( isReserveCacheError || isCacheUnavailable ) {
88- core . warning ( 'Skipping remote cache storage, encountered error:' ) ;
89- core . warning ( error . message ) ;
90- return true ;
91- }
87+ if ( isReserveCacheError || isCacheUnavailable ) {
88+ core . warning ( 'Skipping remote cache storage, encountered error:' ) ;
89+ core . warning ( error . message ) ;
90+ return true ;
91+ }
9292
93- return false ;
93+ return false ;
9494}
0 commit comments