Skip to content

Commit 8fbeb31

Browse files
authored
check if cache dir exists (#171)
1 parent 873b14a commit 8fbeb31

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/build/cache.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { existsSync } from 'node:fs'
12
import { join } from 'node:path'
23

34
import type { PluginContext } from './plugin-context.js'
@@ -11,7 +12,11 @@ export const saveBuildCache = async (ctx: PluginContext) => {
1112
}
1213

1314
export const restoreBuildCache = async (ctx: PluginContext) => {
14-
if (await ctx.utils.cache.restore(join(ctx.publishDir, 'cache'))) {
15+
const { cache } = ctx.utils
16+
17+
if (existsSync(join(ctx.publishDir, 'cache'))) {
18+
console.log('Next.js cache found.')
19+
} else if (await cache.restore(join(ctx.publishDir, 'cache'))) {
1520
console.log('Next.js cache restored.')
1621
} else {
1722
console.log('No Next.js cache to restore.')

0 commit comments

Comments
 (0)