hedgequantx 1.8.17 → 1.8.18
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/utils/prompts.js +23 -26
package/package.json
CHANGED
package/src/utils/prompts.js
CHANGED
|
@@ -1,56 +1,53 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Centralized prompts utility
|
|
3
|
-
* Uses
|
|
3
|
+
* Uses native readline for reliable stdin handling
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const inquirer = require('inquirer');
|
|
7
|
+
const readline = require('readline');
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
|
-
* Ensure stdin is ready
|
|
10
|
+
* Ensure stdin is ready
|
|
10
11
|
*/
|
|
11
12
|
const prepareStdin = () => {
|
|
12
13
|
try {
|
|
13
|
-
// Resume if paused
|
|
14
14
|
if (process.stdin.isPaused()) process.stdin.resume();
|
|
15
|
-
|
|
16
|
-
// Ensure raw mode is off for line-based input
|
|
17
15
|
if (process.stdin.isTTY && process.stdin.setRawMode) {
|
|
18
16
|
process.stdin.setRawMode(false);
|
|
19
17
|
}
|
|
20
|
-
|
|
21
|
-
// Clear any buffered data by removing all listeners temporarily
|
|
22
|
-
const listeners = process.stdin.listeners('data');
|
|
23
|
-
process.stdin.removeAllListeners('data');
|
|
24
|
-
|
|
25
|
-
// Drain any pending input
|
|
26
|
-
process.stdin.read();
|
|
27
|
-
|
|
28
|
-
// Restore listeners
|
|
29
|
-
listeners.forEach(l => process.stdin.on('data', l));
|
|
30
18
|
} catch (e) {}
|
|
31
19
|
};
|
|
32
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Native readline prompt - more reliable than inquirer for simple input
|
|
23
|
+
*/
|
|
24
|
+
const nativePrompt = (message) => {
|
|
25
|
+
return new Promise((resolve) => {
|
|
26
|
+
const rl = readline.createInterface({
|
|
27
|
+
input: process.stdin,
|
|
28
|
+
output: process.stdout
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
rl.question(message + ' ', (answer) => {
|
|
32
|
+
rl.close();
|
|
33
|
+
resolve(answer || '');
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
33
38
|
/**
|
|
34
39
|
* Wait for Enter
|
|
35
40
|
*/
|
|
36
41
|
const waitForEnter = async (message = 'Press Enter to continue...') => {
|
|
37
|
-
|
|
38
|
-
await inquirer.prompt([{ type: 'input', name: '_', message, prefix: '' }]);
|
|
42
|
+
await nativePrompt(message);
|
|
39
43
|
};
|
|
40
44
|
|
|
41
45
|
/**
|
|
42
46
|
* Text input
|
|
43
47
|
*/
|
|
44
48
|
const textInput = async (message, defaultVal = '') => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
type: 'input',
|
|
48
|
-
name: 'value',
|
|
49
|
-
message,
|
|
50
|
-
default: defaultVal,
|
|
51
|
-
prefix: ''
|
|
52
|
-
}]);
|
|
53
|
-
return value;
|
|
49
|
+
const value = await nativePrompt(message);
|
|
50
|
+
return value || defaultVal;
|
|
54
51
|
};
|
|
55
52
|
|
|
56
53
|
/**
|