hedgequantx 1.8.37 → 1.8.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/app.js +6 -1
- package/src/utils/prompts.js +39 -8
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -245,7 +245,12 @@ const run = async () => {
|
|
|
245
245
|
}
|
|
246
246
|
break;
|
|
247
247
|
case 'algotrading':
|
|
248
|
-
|
|
248
|
+
try {
|
|
249
|
+
await algoTradingMenu(currentService);
|
|
250
|
+
} catch (algoErr) {
|
|
251
|
+
console.log(chalk.red(` Algo error: ${algoErr.message}`));
|
|
252
|
+
prepareStdin();
|
|
253
|
+
}
|
|
249
254
|
break;
|
|
250
255
|
case 'update':
|
|
251
256
|
await handleUpdate();
|
package/src/utils/prompts.js
CHANGED
|
@@ -9,6 +9,11 @@ const readline = require('readline');
|
|
|
9
9
|
// Shared readline instance
|
|
10
10
|
let rl = null;
|
|
11
11
|
|
|
12
|
+
// Prevent readline from exiting on SIGINT during prompts
|
|
13
|
+
process.on('SIGINT', () => {
|
|
14
|
+
// Let the main app handle SIGINT
|
|
15
|
+
});
|
|
16
|
+
|
|
12
17
|
/**
|
|
13
18
|
* Get or create readline interface
|
|
14
19
|
*/
|
|
@@ -24,7 +29,7 @@ const getReadline = () => {
|
|
|
24
29
|
};
|
|
25
30
|
|
|
26
31
|
/**
|
|
27
|
-
* Ensure stdin is ready
|
|
32
|
+
* Ensure stdin is ready and flush any buffered input
|
|
28
33
|
*/
|
|
29
34
|
const prepareStdin = () => {
|
|
30
35
|
try {
|
|
@@ -32,6 +37,8 @@ const prepareStdin = () => {
|
|
|
32
37
|
if (process.stdin.isTTY && process.stdin.setRawMode) {
|
|
33
38
|
process.stdin.setRawMode(false);
|
|
34
39
|
}
|
|
40
|
+
// Flush any buffered input by reading without waiting
|
|
41
|
+
process.stdin.read();
|
|
35
42
|
} catch (e) {}
|
|
36
43
|
};
|
|
37
44
|
|
|
@@ -39,13 +46,37 @@ const prepareStdin = () => {
|
|
|
39
46
|
* Native readline prompt
|
|
40
47
|
*/
|
|
41
48
|
const nativePrompt = (message) => {
|
|
42
|
-
return new Promise((resolve) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
try {
|
|
51
|
+
prepareStdin();
|
|
52
|
+
|
|
53
|
+
// Always create a fresh readline for each prompt to avoid state issues
|
|
54
|
+
if (rl && !rl.closed) {
|
|
55
|
+
rl.close();
|
|
56
|
+
rl = null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
rl = readline.createInterface({
|
|
60
|
+
input: process.stdin,
|
|
61
|
+
output: process.stdout,
|
|
62
|
+
terminal: true
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Handle readline close/error
|
|
66
|
+
rl.on('close', () => {
|
|
67
|
+
resolve('');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
rl.on('error', (err) => {
|
|
71
|
+
resolve('');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
rl.question(message + ' ', (answer) => {
|
|
75
|
+
resolve(answer || '');
|
|
76
|
+
});
|
|
77
|
+
} catch (e) {
|
|
78
|
+
resolve('');
|
|
79
|
+
}
|
|
49
80
|
});
|
|
50
81
|
};
|
|
51
82
|
|