@@ -29,7 +29,7 @@ export async function getCache(
29
29
if ( ! option . enable ) {
30
30
return null ;
31
31
}
32
- prepareCacheDir ( option ) ;
32
+ await prepareCacheDir ( option ) ;
33
33
34
34
const key = getKey ( id , source ) ;
35
35
const path = getCachePath ( key , option ) ;
@@ -74,7 +74,7 @@ export async function setCache(
74
74
if ( ! option . enable ) {
75
75
return ;
76
76
}
77
- prepareCacheDir ( option ) ;
77
+ await prepareCacheDir ( option ) ;
78
78
79
79
const key = getKey ( id , source ) ;
80
80
const path = getCachePath ( key , option ) ;
@@ -87,7 +87,7 @@ export async function setCache(
87
87
88
88
const cache = data + hashComment ;
89
89
if ( isBun ( ) ) {
90
- Bun . write ( path , cache , { createPath : true } ) ;
90
+ await Bun . write ( path , cache , { createPath : true } ) ;
91
91
}
92
92
else {
93
93
await writeFile ( path , cache , { encoding : 'utf8' } ) ;
@@ -125,13 +125,14 @@ async function prepareCacheDir(option: ResolvedCacheOptions) {
125
125
if ( cacheDir != null ) {
126
126
return ;
127
127
}
128
- await mkdir ( option . base , { recursive : true } ) ;
128
+ const _cacheDir = option . base ;
129
+ await mkdir ( _cacheDir , { recursive : true } ) ;
129
130
130
- if ( ! isWritable ) {
131
+ if ( ! await isWritable ( _cacheDir ) ) {
131
132
throw new Error ( 'Cache directory is not writable.' ) ;
132
133
}
133
134
134
- cacheDir = option . base ;
135
+ cacheDir = _cacheDir ;
135
136
}
136
137
137
138
async function isWritable ( filename : string ) : Promise < boolean > {
0 commit comments