Skip to content

Commit 27f4303

Browse files
committed
Unify typings of new password prompt
1 parent d698e34 commit 27f4303

File tree

4 files changed

+13
-35
lines changed

4 files changed

+13
-35
lines changed

README.md

+6-32
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ A collection of common interactive command line user interfaces.
2222
2. [User Interfaces and Layouts](#layouts)
2323
1. [Reactive Interface](#reactive)
2424
3. [Support](#support)
25-
4. [Nodemon](#nodemon-support)
26-
5. [Known issues](#issues)
27-
6. [News](#news)
28-
7. [Contributing](#contributing)
29-
8. [License](#license)
30-
9. [Plugins](#plugins)
25+
4. [Known issues](#issues)
26+
5. [News](#news)
27+
6. [Contributing](#contributing)
28+
7. [License](#license)
29+
8. [Plugins](#plugins)
3130

3231
## Goal and Philosophy
3332

@@ -136,8 +135,7 @@ prompt(questions).then(/* ... */);
136135
<a name="questions"></a>
137136
A question object is a `hash` containing question related values:
138137

139-
- **type**: (String) Type of the prompt. Defaults: `input` - Possible values: `input`, `number`, `confirm`,
140-
`list`, `rawlist`, `expand`, `checkbox`, `password`, `editor`
138+
- **type**: (String) Type of the prompt. Defaults: `input` - Possible values: `input`, `number`, `confirm`, `list`, `rawlist`, `expand`, `checkbox`, `password`, `editor`
141139
- **name**: (String) The name to use when storing the answer in the answers hash. If the name contains periods, it will define a path in the answers hash.
142140
- **message**: (String|Function) The question to print. If defined as a function, the first parameter will be the current inquirer session answers. Defaults to the value of `name` (followed by a colon).
143141
- **default**: (String|Number|Boolean|Array|Function) Default value(s) to use if nothing is entered, or a function that returns the default value(s). If defined as a function, the first parameter will be the current inquirer session answers.
@@ -387,30 +385,6 @@ look at issues found on other command line - feel free to report any!
387385
- gnome-terminal (Terminal GNOME)
388386
- konsole
389387

390-
## Nodemon Support
391-
392-
When executing with [`Nodemon`](https://www.npmjs.com/package/nodemon), you'll need to set `stdin: false` in your config:
393-
394-
```diff
395-
{
396-
"watch": [
397-
"dist/"
398-
],
399-
"ext": "js, json",
400-
+ "stdin": false,
401-
"ignore": [
402-
"src/*/.spec.ts",
403-
"typescript",
404-
"node_modules"
405-
],
406-
"events": {
407-
"start": "cls || clear"
408-
},
409-
"script": "dist/myApp.js",
410-
"restartable": false
411-
}
412-
```
413-
414388
## Known issues
415389

416390
<a name="issues"></a>

packages/password/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/password/README.md",
5555
"dependencies": {
5656
"@inquirer/input": "^0.0.27-alpha.0",
57+
"@inquirer/type": "^0.0.3-alpha.0",
5758
"chalk": "^5.0.1"
5859
},
5960
"scripts": {

packages/password/src/index.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import type { Prompt } from '@inquirer/type';
12
import input from '@inquirer/input';
23
import chalk from 'chalk';
34

45
type PasswordConfig = Parameters<typeof input>[0] & {
56
mask?: boolean | string;
67
};
78

8-
export default (config: PasswordConfig, stdio?: Parameters<typeof input>[1]) => {
9+
const password: Prompt<string, PasswordConfig> = (config, context) => {
910
if (config.transformer) {
1011
throw new Error(
1112
'Inquirer password prompt do not support custom transformer function. Use the input prompt instead.'
@@ -28,6 +29,8 @@ export default (config: PasswordConfig, stdio?: Parameters<typeof input>[1]) =>
2829
return '';
2930
},
3031
},
31-
stdio
32+
context
3233
);
3334
};
35+
36+
export default password;

packages/type/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
type Context = {
1+
export type Context = {
22
input?: NodeJS.ReadableStream;
33
output?: NodeJS.WritableStream;
44
clearPromptOnDone?: boolean;

0 commit comments

Comments
 (0)