Skip to content

Commit 513a105

Browse files
authored
Merge pull request #36 from CommandAI/fix_aic
double run on bang
2 parents 798a51e + f98de6d commit 513a105

4 files changed

Lines changed: 37 additions & 5 deletions

File tree

.vscode/launch.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,32 @@
1414
],
1515
"console": "integratedTerminal"
1616
},
17+
{
18+
"type": "node",
19+
"request": "launch",
20+
"name": "aiChat",
21+
"skipFiles": [
22+
"<node_internals>/**"
23+
],
24+
"program": "${workspaceFolder}/aic.js",
25+
"args": [
26+
"how much would a woodchuck chuk "
27+
],
28+
"console": "integratedTerminal"
29+
},
30+
{
31+
"type": "node",
32+
"request": "launch",
33+
"name": "aiChat",
34+
"skipFiles": [
35+
"<node_internals>/**"
36+
],
37+
"program": "${workspaceFolder}/aic!.js",
38+
"args": [
39+
"how much would a woodchuck chuk "
40+
],
41+
"console": "integratedTerminal"
42+
},
1743
{
1844
"type": "node",
1945
"request": "launch",

ai.js

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

150-
main();
150+
if (import.meta.url === `file://${process.argv[1]}`) {
151+
main();
152+
}
151153

152154
export default main;

aic.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ async function askQuestion(question, client) {
3737
spinner.fail(gradient.cristal("Failed to get response."));
3838
logger.error({ error: error.message }, "Error occurred.");
3939
}
40-
process.exit(0);
4140
}
4241

4342
async function chatPrompt() {
@@ -72,7 +71,7 @@ async function startConversation(client, initialQuestion) {
7271
}
7372

7473
console.log(gradient.morning("Goodbye!"));
75-
process.exit();
74+
process.exit(0);
7675
}
7776

7877
function shouldExitConversation(question, exitWords) {
@@ -89,12 +88,15 @@ async function main(startConvo = true) {
8988
} else {
9089
await askQuestion(command, client);
9190
}
91+
process.exit(0);
9292
} catch (error) {
9393
logger.error(`An error occurred: ${error.message}`);
9494
process.exit(1);
9595
}
9696
}
9797

98-
main();
98+
if (import.meta.url === `file://${process.argv[1]}`) {
99+
main();
100+
}
99101

100102
export default main;

aiq.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,8 @@ async function main(prompt = true) {
487487
process.exit(0);
488488
}
489489

490-
main();
490+
if (import.meta.url === `file://${process.argv[1]}`) {
491+
main();
492+
}
491493

492494
export default main;

0 commit comments

Comments
 (0)