@oclif/core 3.19.5 → 3.19.6

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.
@@ -28,38 +28,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.anykey = exports.confirm = exports.prompt = void 0;
30
30
  const chalk_1 = __importDefault(require("chalk"));
31
- const node_readline_1 = __importDefault(require("node:readline"));
32
31
  const Errors = __importStar(require("../errors"));
33
32
  const config_1 = require("./config");
34
33
  function normal(options, retries = 100) {
35
34
  if (retries < 0)
36
35
  throw new Error('no input');
37
- const ac = new AbortController();
38
- const { signal } = ac;
39
36
  return new Promise((resolve, reject) => {
40
- const rl = node_readline_1.default.createInterface({
41
- input: process.stdin,
42
- output: process.stdout,
43
- });
44
- let timeout;
45
- // Only set the timeout if the input is a TTY
46
- if (options.timeout && options.isTTY) {
47
- timeout = setTimeout(() => ac.abort(), options.timeout);
48
- signal.addEventListener('abort', () => {
49
- rl.close();
50
- clearTimeout(timeout);
37
+ let timer;
38
+ if (options.timeout) {
39
+ timer = setTimeout(() => {
40
+ process.stdin.pause();
51
41
  reject(new Error('Prompt timeout'));
52
- }, { once: true });
42
+ }, options.timeout);
43
+ timer.unref();
53
44
  }
54
- rl.question(options.prompt, { signal }, (answer) => {
55
- rl.close();
56
- const data = answer.trim();
45
+ process.stdin.setEncoding('utf8');
46
+ process.stderr.write(options.prompt);
47
+ process.stdin.resume();
48
+ process.stdin.once('data', (b) => {
49
+ if (timer)
50
+ clearTimeout(timer);
51
+ process.stdin.pause();
52
+ const data = (typeof b === 'string' ? b : b.toString()).trim();
57
53
  if (!options.default && options.required && data === '') {
58
- clearTimeout(timeout);
59
54
  resolve(normal(options, retries - 1));
60
55
  }
61
56
  else {
62
- clearTimeout(timeout);
63
57
  resolve(data || options.default);
64
58
  }
65
59
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "3.19.5",
4
+ "version": "3.19.6",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {