diff --git a/packages/cli-tools/src/cacheManager.ts b/packages/cli-tools/src/cacheManager.ts index 367d7b513b..53b0c834e2 100644 --- a/packages/cli-tools/src/cacheManager.ts +++ b/packages/cli-tools/src/cacheManager.ts @@ -26,10 +26,13 @@ function loadCache(name: string): Cache | undefined { } function saveCache(name: string, cache: Cache) { - fs.writeFileSync( - path.resolve(getCacheRootPath(), name), - JSON.stringify(cache, null, 2), - ); + const fullPath = path.resolve(getCacheRootPath(), name); + + const dir = path.dirname(fullPath); + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); + } + fs.writeFileSync(fullPath, JSON.stringify(cache, null, 2)); } /**