Skip to content

Commit c0c8e50

Browse files
committed
better terminal compatibility.
1 parent 4ae6a76 commit c0c8e50

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

packages/agent/src/utils/userPrompt.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
import * as readline from 'readline';
1+
import { createInterface } from 'readline/promises';
22

33
import chalk from 'chalk';
44

55
export const userPrompt = async (prompt: string): Promise<string> => {
6-
const rl = readline.createInterface({
6+
const rl = createInterface({
77
input: process.stdin,
88
output: process.stdout,
9-
terminal: true,
109
});
1110

1211
try {
13-
// Disable the readline interface's internal input processing
14-
if (rl.terminal) {
15-
process.stdin.setRawMode(false);
16-
}
17-
return await new Promise<string>((resolve) => {
18-
rl.question(chalk.green('\n' + prompt + '\n') + '\n> ', (answer) => {
19-
resolve(answer);
20-
});
21-
});
12+
return await rl.question(chalk.green('\n' + prompt + '\n') + '\n> ');
2213
} finally {
2314
rl.close();
2415
}

0 commit comments

Comments
 (0)