Skip to content

Commit

Permalink
fix: check for valid cache removal when running with no cache
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed May 22, 2024
1 parent 3ad552e commit 4cbb47c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/core/src/unlighthouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,14 @@ export async function createUnlighthouse(userConfig: UserConfig, provider?: Prov
})
}

if (!resolvedConfig.cache && existsSync(resolvedConfig.outputPath)) {
logger.debug(`\`cache\` is disabled, deleting cache folder: \`${resolvedConfig.outputPath}\``)
fs.rmSync(ctx.runtimeSettings.outputPath, { recursive: true })
if (!resolvedConfig.cache && existsSync(ctx.runtimeSettings.outputPath)) {
logger.debug(`\`cache\` is disabled, deleting cache folder: \`${ctx.runtimeSettings.outputPath}\``)
try {
fs.rmSync(ctx.runtimeSettings.outputPath, { recursive: true })
}
catch (e) {
logger.debug(`Failed to delete cache folder: \`${ctx.runtimeSettings.outputPath}\``, e)
}
}
fs.ensureDirSync(ctx.runtimeSettings.outputPath)
await generateClient()
Expand Down

0 comments on commit 4cbb47c

Please sign in to comment.