hedgequantx 1.8.16 → 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 +25 -13
package/package.json
CHANGED
package/src/utils/prompts.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
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
10
|
* Ensure stdin is ready
|
|
@@ -11,31 +12,42 @@ const inquirer = require('inquirer');
|
|
|
11
12
|
const prepareStdin = () => {
|
|
12
13
|
try {
|
|
13
14
|
if (process.stdin.isPaused()) process.stdin.resume();
|
|
14
|
-
if (process.stdin.isTTY && process.stdin.
|
|
15
|
+
if (process.stdin.isTTY && process.stdin.setRawMode) {
|
|
16
|
+
process.stdin.setRawMode(false);
|
|
17
|
+
}
|
|
15
18
|
} catch (e) {}
|
|
16
19
|
};
|
|
17
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
|
+
|
|
18
38
|
/**
|
|
19
39
|
* Wait for Enter
|
|
20
40
|
*/
|
|
21
41
|
const waitForEnter = async (message = 'Press Enter to continue...') => {
|
|
22
|
-
|
|
23
|
-
await inquirer.prompt([{ type: 'input', name: '_', message, prefix: '' }]);
|
|
42
|
+
await nativePrompt(message);
|
|
24
43
|
};
|
|
25
44
|
|
|
26
45
|
/**
|
|
27
46
|
* Text input
|
|
28
47
|
*/
|
|
29
48
|
const textInput = async (message, defaultVal = '') => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
type: 'input',
|
|
33
|
-
name: 'value',
|
|
34
|
-
message,
|
|
35
|
-
default: defaultVal,
|
|
36
|
-
prefix: ''
|
|
37
|
-
}]);
|
|
38
|
-
return value;
|
|
49
|
+
const value = await nativePrompt(message);
|
|
50
|
+
return value || defaultVal;
|
|
39
51
|
};
|
|
40
52
|
|
|
41
53
|
/**
|