Skip to content

Commit

Permalink
fix: handle when wrangler.toml is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jan 22, 2024
1 parent 88d91ff commit 0340c1d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { relative, resolve } from "node:path";
import type { Nitro } from "nitropack";
import type { Nuxt } from "nuxt/schema";
import consola from "consola";
import { colorize } from "consola/utils";
import { findFile } from "pkg-types";

export {} from "./types";
Expand All @@ -15,7 +16,7 @@ async function nitroModule(nitro: Nitro) {
// Find wrangler.toml
const configPath = await findFile("wrangler.toml", {
startingFrom: nitro.options.srcDir,
});
}).catch(() => undefined);

// Resolve the persist dir
const persistDir = resolve(nitro.options.rootDir, ".wrangler/state/v3");
Expand All @@ -24,7 +25,7 @@ async function nitroModule(nitro: Nitro) {
[
"🔥 Cloudflare context bindings enabled for dev server",
"",
`Config path: \`${relative(".", configPath)}\``,
`Config path: ${configPath ? relative(".", configPath) : colorize("yellow", "cannot find `wrangler.toml`")}`,
`Persist dir: \`${relative(".", persistDir)}\``,
].join("\n"),
);
Expand Down

0 comments on commit 0340c1d

Please sign in to comment.