[PR #3749] [MERGED] fix: --yes option does not work on @better-auth/cli generate #4987

Closed
opened 2026-03-13 12:06:25 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3749
Author: @phanect
Created: 8/2/2025
Status: Merged
Merged: 8/2/2025
Merged by: @Bekacru

Base: mainHead: fix-cli-generate-yes


📝 Commits (2)

  • e5bd0d0 fix: do not prompt before overwriting schema on @better-auth/cli generate --yes ...
  • 4b1dc6f chore: changeset

📊 Changes

2 files changed (+6 additions, -1 deletions)

View changed files

.changeset/twenty-camels-float.md (+5 -0)
📝 packages/cli/src/commands/generate.ts (+1 -1)

📄 Description

If you run pnpx @better-auth/cli generate --yes ... and the targeted output file already exists, the prompt asks if the file should be overwritten, while it should not ask when you add the --yes option.
This PR makes the --yes option work as expected.

Current behavior

--yes does not prevent the prompt:

$ pnpx @better-auth/cli generate --yes --output="./path/to/schema.ts"
✔ The file ./path/to/schema.ts already exists. Do you want to overwrite the schema to the file? › (y/N)

-y does not prevent the prompt either:

$ pnpx @better-auth/cli generate -y --output="./path/to/schema.ts"
✔ The file ./path/to/schema.ts already exists. Do you want to overwrite the schema to the file? › (y/N)

Only the deprecated --y allows you to overwrite the file without prompt:

$ pnpx @better-auth/cli generate --y --output="./path/to/schema.ts"
2025-08-02T05:48:33.216Z SUCCESS [Better Auth]: 🚀 Schema was overwritten successfully!

Step to reproduce the bug

Run the following command:

$ touch ./path/to/schema.ts # Create a dummy file to overwrite
$ pnpx @better-auth/cli generate --yes --output="./path/to/schema.ts"

Expected: @better-auth/cli overwrites ./path/to/schema.ts without any prompts.

Actual: The following prompt is shown, and the command process is paused.

✔ The file ./path/to/schema.ts already exists. Do you want to overwrite the schema to the file? › (y/N)

Summary by cubic

Fixed the --yes option in @better-auth/cli generate so it now overwrites files without prompting when used.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/3749 **Author:** [@phanect](https://github.com/phanect) **Created:** 8/2/2025 **Status:** ✅ Merged **Merged:** 8/2/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `fix-cli-generate-yes` --- ### 📝 Commits (2) - [`e5bd0d0`](https://github.com/better-auth/better-auth/commit/e5bd0d083f216b0522e60162380e86cec85d9d90) fix: do not prompt before overwriting schema on `@better-auth/cli generate --yes ...` - [`4b1dc6f`](https://github.com/better-auth/better-auth/commit/4b1dc6fd9aa109d1eea02dccb97be0d422d3fe41) chore: changeset ### 📊 Changes **2 files changed** (+6 additions, -1 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/twenty-camels-float.md` (+5 -0) 📝 `packages/cli/src/commands/generate.ts` (+1 -1) </details> ### 📄 Description If you run `pnpx @better-auth/cli generate --yes ...` and the targeted output file already exists, the prompt asks if the file should be overwritten, while it should not ask when you add the `--yes` option. This PR makes the `--yes` option work as expected. # Current behavior `--yes` does not prevent the prompt: ```sh $ pnpx @better-auth/cli generate --yes --output="./path/to/schema.ts" ✔ The file ./path/to/schema.ts already exists. Do you want to overwrite the schema to the file? › (y/N) ``` `-y` does not prevent the prompt either: ```sh $ pnpx @better-auth/cli generate -y --output="./path/to/schema.ts" ✔ The file ./path/to/schema.ts already exists. Do you want to overwrite the schema to the file? › (y/N) ``` Only the deprecated `--y` allows you to overwrite the file without prompt: ```sh $ pnpx @better-auth/cli generate --y --output="./path/to/schema.ts" 2025-08-02T05:48:33.216Z SUCCESS [Better Auth]: 🚀 Schema was overwritten successfully! ``` # Step to reproduce the bug Run the following command: ```sh $ touch ./path/to/schema.ts # Create a dummy file to overwrite $ pnpx @better-auth/cli generate --yes --output="./path/to/schema.ts" ``` Expected: `@better-auth/cli` overwrites ./path/to/schema.ts without any prompts. Actual: The following prompt is shown, and the command process is paused. ```sh ✔ The file ./path/to/schema.ts already exists. Do you want to overwrite the schema to the file? › (y/N) ``` <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixed the `--yes` option in `@better-auth/cli generate` so it now overwrites files without prompting when used. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:06:25 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#4987