@inquirer/prompts 2.0.0 → 2.1.0

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.
Files changed (2) hide show
  1. package/README.md +25 -5
  2. package/package.json +11 -11
package/README.md CHANGED
@@ -200,20 +200,40 @@ if (allowEmail) {
200
200
  ## Get default value after timeout
201
201
 
202
202
  ```js
203
+ import { setTimeout } from 'node:timers/promises';
203
204
  import { input } from '@inquirer/prompts';
204
205
 
205
206
  const answer = input(...);
206
207
 
207
- const defaultValue = new Promise(resolve => {
208
- setTimeout(() => {
209
- resolve(...);
210
- answer.cancel();
211
- }, 5000);
208
+ const defaultValue = setTimeout(5000).then(() => {
209
+ answer.cancel();
210
+ return 'default answer';
212
211
  });
213
212
 
214
213
  const answer = await Promise.race([defaultValue, answer])
215
214
  ```
216
215
 
216
+ ## Using as pre-commit/git hooks, or scripts
217
+
218
+ By default scripts ran from tools like `husky`/`lint-staged` might not run inside an interactive shell. In non-interactive shell, Inquirer cannot run, and users cannot send keypress events to the process.
219
+
220
+ For it to work, you must make sure you start a `tty` (or "interactive" input stream.)
221
+
222
+ If those scripts are set within your `package.json`, you can define the stream like so:
223
+
224
+ ```json
225
+ "precommit": "my-script < /dev/tty"
226
+ ```
227
+
228
+ Or if in a shell script file, you'll do it like so: (on Windows that's likely your only option)
229
+
230
+ ```sh
231
+ #!/bin/sh
232
+ exec < /dev/tty
233
+
234
+ node my-script.js
235
+ ```
236
+
217
237
  # Community prompts
218
238
 
219
239
  If you created a cool prompt, [send us a PR adding it](https://github.com/SBoudrias/Inquirer.js/edit/master/README.md) to the list below!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/prompts",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
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.cts",
@@ -77,16 +77,16 @@
77
77
  }
78
78
  },
79
79
  "dependencies": {
80
- "@inquirer/checkbox": "^1.3.0",
81
- "@inquirer/confirm": "^2.0.0",
82
- "@inquirer/core": "^2.0.0",
83
- "@inquirer/editor": "^1.1.0",
84
- "@inquirer/expand": "^1.1.0",
85
- "@inquirer/input": "^1.2.0",
86
- "@inquirer/password": "^1.1.0",
87
- "@inquirer/rawlist": "^1.2.0",
88
- "@inquirer/select": "^1.2.0"
80
+ "@inquirer/checkbox": "^1.3.1",
81
+ "@inquirer/confirm": "^2.0.1",
82
+ "@inquirer/core": "^2.1.0",
83
+ "@inquirer/editor": "^1.2.0",
84
+ "@inquirer/expand": "^1.1.1",
85
+ "@inquirer/input": "^1.2.1",
86
+ "@inquirer/password": "^1.1.1",
87
+ "@inquirer/rawlist": "^1.2.1",
88
+ "@inquirer/select": "^1.2.1"
89
89
  },
90
90
  "homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/prompts/README.md",
91
- "gitHead": "86531864067faf1d6e76f1581c9aa72cb1b03753"
91
+ "gitHead": "d48ecde923e5875de631f7b50f67cfaf00384947"
92
92
  }