@inquirer/prompts 4.3.0 → 4.3.1
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/README.md +15 -5
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -203,14 +203,24 @@ if (allowEmail) {
|
|
|
203
203
|
import { setTimeout } from 'node:timers/promises';
|
|
204
204
|
import { input } from '@inquirer/prompts';
|
|
205
205
|
|
|
206
|
-
const
|
|
206
|
+
const ac = new AbortController();
|
|
207
|
+
const prompt = input({
|
|
208
|
+
message: 'Enter a value (timing out in 5 seconds)',
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
prompt
|
|
212
|
+
.finally(() => {
|
|
213
|
+
ac.abort();
|
|
214
|
+
})
|
|
215
|
+
// Silencing the cancellation error.
|
|
216
|
+
.catch(() => {});
|
|
207
217
|
|
|
208
|
-
const defaultValue = setTimeout(5000).then(() => {
|
|
209
|
-
|
|
210
|
-
return '
|
|
218
|
+
const defaultValue = setTimeout(5000, 'timeout', { signal: ac.signal }).then(() => {
|
|
219
|
+
prompt.cancel();
|
|
220
|
+
return 'Timed out!';
|
|
211
221
|
});
|
|
212
222
|
|
|
213
|
-
const answer = await Promise.race([defaultValue,
|
|
223
|
+
const answer = await Promise.race([defaultValue, prompt]);
|
|
214
224
|
```
|
|
215
225
|
|
|
216
226
|
## Using as pre-commit/git hooks, or scripts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/prompts",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"description": "Inquirer prompts, combined in a single package",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"typings": "./dist/cjs/types/index.d.ts",
|
|
@@ -76,16 +76,16 @@
|
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@inquirer/checkbox": "^2.2.
|
|
80
|
-
"@inquirer/confirm": "^3.1.
|
|
81
|
-
"@inquirer/core": "^7.1.
|
|
82
|
-
"@inquirer/editor": "^2.1.
|
|
83
|
-
"@inquirer/expand": "^2.1.
|
|
84
|
-
"@inquirer/input": "^2.1.
|
|
85
|
-
"@inquirer/password": "^2.1.
|
|
86
|
-
"@inquirer/rawlist": "^2.1.
|
|
87
|
-
"@inquirer/select": "^2.2.
|
|
79
|
+
"@inquirer/checkbox": "^2.2.1",
|
|
80
|
+
"@inquirer/confirm": "^3.1.1",
|
|
81
|
+
"@inquirer/core": "^7.1.1",
|
|
82
|
+
"@inquirer/editor": "^2.1.1",
|
|
83
|
+
"@inquirer/expand": "^2.1.1",
|
|
84
|
+
"@inquirer/input": "^2.1.1",
|
|
85
|
+
"@inquirer/password": "^2.1.1",
|
|
86
|
+
"@inquirer/rawlist": "^2.1.1",
|
|
87
|
+
"@inquirer/select": "^2.2.1"
|
|
88
88
|
},
|
|
89
89
|
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/prompts/README.md",
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "086fb1c59092cba248e55583d92f34e4eec44b2d"
|
|
91
91
|
}
|