Skip to content

Commit 5da66b7

Browse files
committed
checks for output directory / enabled
1 parent 541407f commit 5da66b7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

packages/cloudflare/src/cli/build/utils/populate-cache.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { spawnSync } from "node:child_process";
2+
import { existsSync } from "node:fs";
23
import path from "node:path";
34

45
import type { BuildOptions } from "@opennextjs/aws/build/helper.js";
@@ -35,15 +36,25 @@ function runWrangler(opts: BuildOptions, mode: CacheBindingMode, args: string[])
3536

3637
if (result.status !== 0) {
3738
logger.error("Failed to populate cache");
39+
process.exit(1);
3840
} else {
3941
logger.info("Successfully populated cache");
4042
}
4143
}
4244

4345
export async function populateCache(opts: BuildOptions, config: OpenNextConfig, mode: CacheBindingMode) {
44-
const { tagCache } = config.default.override ?? {};
46+
const { incrementalCache, tagCache } = config.default.override ?? {};
4547

46-
if (tagCache) {
48+
if (!existsSync(opts.outputDir)) {
49+
logger.error("Unable to populate cache: Open Next build not found");
50+
process.exit(1);
51+
}
52+
53+
if (!config.dangerous?.disableIncrementalCache && incrementalCache) {
54+
logger.info("Incremental cache does not need populating");
55+
}
56+
57+
if (!config.dangerous?.disableTagCache && tagCache) {
4758
const name = await resolveCacheName(tagCache);
4859
switch (name) {
4960
case "d1-tag-cache": {
@@ -56,6 +67,8 @@ export async function populateCache(opts: BuildOptions, config: OpenNextConfig,
5667
]);
5768
break;
5869
}
70+
default:
71+
logger.info("Tag cache does not need populating");
5972
}
6073
}
6174
}

0 commit comments

Comments
 (0)