Skip to content

Commit

Permalink
feat: automatically add .wrangler/state/v3 to .gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jan 22, 2024
1 parent 0340c1d commit 5bf2c5b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/nuxt/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ logs
.env
.env.*
!.env.example

.wrangler/state/v3
13 changes: 13 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { fileURLToPath } from "node:url";
import { relative, resolve } from "node:path";
import { promises as fs } from "node:fs";
import type { Nitro } from "nitropack";
import type { Nuxt } from "nuxt/schema";
import consola from "consola";
Expand All @@ -21,6 +22,18 @@ async function nitroModule(nitro: Nitro) {
// Resolve the persist dir
const persistDir = resolve(nitro.options.rootDir, ".wrangler/state/v3");

// Add `.wrnagle/state/v3` to `.gitignore`
const gitIgnorePath = await findFile(".gitignore", {
startingFrom: nitro.options.rootDir,
}).catch(() => undefined);
if (gitIgnorePath) {
const gitIgnore = await fs.readFile(gitIgnorePath, "utf8");
if (!gitIgnore.includes(".wrangler/state/v3")) {
consola.info("Adding `.wrangler/state/v3` to `.gitignore`...");
await fs.writeFile(gitIgnorePath, gitIgnore + "\n.wrangler/state/v3\n");
}
}

consola.box(
[
"🔥 Cloudflare context bindings enabled for dev server",
Expand Down

0 comments on commit 5bf2c5b

Please sign in to comment.