diff --git a/.changeset/khaki-suns-boil.md b/.changeset/khaki-suns-boil.md new file mode 100644 index 000000000000..d5e25dfa6e13 --- /dev/null +++ b/.changeset/khaki-suns-boil.md @@ -0,0 +1,5 @@ +--- +"wrangler": patch +--- + +fix d1 directory not being created when running the `wrangler d1 execute` command with the `--yes`/`-y` flag diff --git a/packages/wrangler/src/d1/execute.tsx b/packages/wrangler/src/d1/execute.tsx index 37d3e8bda019..18aac181283e 100644 --- a/packages/wrangler/src/d1/execute.tsx +++ b/packages/wrangler/src/d1/execute.tsx @@ -200,10 +200,10 @@ async function executeLocally( logger.log ); - if (!existsSync(dbDir) && shouldPrompt) { - const ok = await confirm( - `About to create ${readableRelative(dbPath)}, ok?` - ); + if (!existsSync(dbDir)) { + const ok = + !shouldPrompt || + (await confirm(`About to create ${readableRelative(dbPath)}, ok?`)); if (!ok) return null; await mkdir(dbDir, { recursive: true }); }