Skip to content

Commit 7baa339

Browse files
fix: treat git bash as un-interactive (#1222)
* handle git bash * better message * changeset
1 parent b7a57c3 commit 7baa339

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

Diff for: .changeset/red-ducks-jam.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-t3-app": patch
3+
---
4+
5+
fix: detect and handle git bash environment

Diff for: cli/src/cli/index.ts

+31-4
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,19 @@ export const runCli = async () => {
156156

157157
// Explained below why this is in a try/catch block
158158
try {
159+
if (
160+
process.env.SHELL?.toLowerCase().includes("git") &&
161+
process.env.SHELL?.includes("bash")
162+
) {
163+
logger.warn(` WARNING: It looks like you are using Git Bash which is non-interactive. Please run create-t3-app with another
164+
terminal such as Windows Terminal or PowerShell if you want to use the interactive CLI.`);
165+
166+
const error = new Error("Non-interactive environment");
167+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
168+
(error as any).isTTYError = true;
169+
throw error;
170+
}
171+
159172
// if --CI flag is set, we are running in CI mode and should not prompt the user
160173
// if --default flag is set, we should not prompt the user
161174
if (!cliResults.flags.default && !CIMode) {
@@ -181,10 +194,24 @@ export const runCli = async () => {
181194
// Otherwise we have to do some fancy namespace extension logic on the Error type which feels overkill for one line
182195
// eslint-disable-next-line @typescript-eslint/no-explicit-any
183196
if (err instanceof Error && (err as any).isTTYError) {
184-
logger.warn(
185-
`${CREATE_T3_APP} needs an interactive terminal to provide options`,
186-
);
187-
logger.info(`Bootstrapping a default t3 app in ./${cliResults.appName}`);
197+
logger.warn(`
198+
${CREATE_T3_APP} needs an interactive terminal to provide options`);
199+
200+
const { shouldContinue } = await inquirer.prompt<{
201+
shouldContinue: boolean;
202+
}>({
203+
name: "shouldContinue",
204+
type: "confirm",
205+
message: `Continue scaffolding a default T3 app?`,
206+
default: true,
207+
});
208+
209+
if (!shouldContinue) {
210+
logger.info("Exiting...");
211+
process.exit(0);
212+
}
213+
214+
logger.info(`Bootstrapping a default T3 app in ./${cliResults.appName}`);
188215
} else {
189216
throw err;
190217
}

0 commit comments

Comments
 (0)