Skip to content

Commit a6a69a0

Browse files
committed
fix goodbye issue and ai's not working
1 parent 842ede4 commit a6a69a0

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

ai.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ async function main(continuePrompt = true) {
147147
}
148148
}
149149

150-
if (import.meta.url === `file://${process.argv[1]}`) {
150+
151+
if (!`file://${process.argv[1]}`.includes('!')) {
151152
main();
152153
}
153154

aic.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ async function chatPrompt() {
5151
}
5252

5353
async function startConversation(client, initialQuestion) {
54-
const exitWords = new Set(["exit", "goodbye", "quit"]);
55-
5654
let continueConversation = true;
5755
let question = initialQuestion;
5856

@@ -61,7 +59,7 @@ async function startConversation(client, initialQuestion) {
6159
question = await chatPrompt();
6260
}
6361

64-
if (shouldExitConversation(question, exitWords)) {
62+
if (shouldExitConversation(question)) {
6563
continueConversation = false;
6664
break;
6765
}
@@ -74,7 +72,8 @@ async function startConversation(client, initialQuestion) {
7472
process.exit(0);
7573
}
7674

77-
function shouldExitConversation(question, exitWords) {
75+
function shouldExitConversation(question) {
76+
const exitWords = new Set(["exit", "goodbye", "quit"]);
7877
return !question || exitWords.has(question.toLowerCase().trim());
7978
}
8079

@@ -95,7 +94,7 @@ async function main(startConvo = true) {
9594
}
9695
}
9796

98-
if (import.meta.url === `file://${process.argv[1]}`) {
97+
if (!`file://${process.argv[1]}`.includes('!')) {
9998
main();
10099
}
101100

aiq.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,11 @@ async function promptConnectionDetails(existingConfig = {}) {
429429
};
430430
}
431431

432+
function shouldExitConversation(question) {
433+
const exitWords = new Set(["exit", "goodbye", "quit"]);
434+
return !question || exitWords.has(question.toLowerCase().trim());
435+
}
436+
432437
async function promptForCommands(dbConfigs, connectionNameOrFile, client) {
433438
let command;
434439
do {
@@ -441,10 +446,12 @@ async function promptForCommands(dbConfigs, connectionNameOrFile, client) {
441446
]);
442447
command = input.command;
443448

444-
if (command.toLowerCase() !== "exit") {
445-
await processQuery(dbConfigs, connectionNameOrFile, command, client);
449+
if (shouldExitConversation(command)) {
450+
break;
446451
}
447-
} while (command.toLowerCase() !== "exit");
452+
453+
await processQuery(dbConfigs, connectionNameOrFile, command, client);
454+
} while (true);
448455
}
449456

450457
async function handleNoOrSingleParam() {
@@ -487,7 +494,7 @@ async function main(prompt = true) {
487494
process.exit(0);
488495
}
489496

490-
if (import.meta.url === `file://${process.argv[1]}`) {
497+
if (!`file://${process.argv[1]}`.includes('!')) {
491498
main();
492499
}
493500

0 commit comments

Comments
 (0)