Skip to content

Commit

Permalink
Unify typings of new password prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed Oct 6, 2022
1 parent d698e34 commit 27f4303
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 35 deletions.
38 changes: 6 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ A collection of common interactive command line user interfaces.
2. [User Interfaces and Layouts](#layouts)
1. [Reactive Interface](#reactive)
3. [Support](#support)
4. [Nodemon](#nodemon-support)
5. [Known issues](#issues)
6. [News](#news)
7. [Contributing](#contributing)
8. [License](#license)
9. [Plugins](#plugins)
4. [Known issues](#issues)
5. [News](#news)
6. [Contributing](#contributing)
7. [License](#license)
8. [Plugins](#plugins)

## Goal and Philosophy

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

- **type**: (String) Type of the prompt. Defaults: `input` - Possible values: `input`, `number`, `confirm`,
`list`, `rawlist`, `expand`, `checkbox`, `password`, `editor`
- **type**: (String) Type of the prompt. Defaults: `input` - Possible values: `input`, `number`, `confirm`, `list`, `rawlist`, `expand`, `checkbox`, `password`, `editor`
- **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.
- **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).
- **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.
Expand Down Expand Up @@ -387,30 +385,6 @@ look at issues found on other command line - feel free to report any!
- gnome-terminal (Terminal GNOME)
- konsole

## Nodemon Support

When executing with [`Nodemon`](https://www.npmjs.com/package/nodemon), you'll need to set `stdin: false` in your config:

```diff
{
"watch": [
"dist/"
],
"ext": "js, json",
+ "stdin": false,
"ignore": [
"src/*/.spec.ts",
"typescript",
"node_modules"
],
"events": {
"start": "cls || clear"
},
"script": "dist/myApp.js",
"restartable": false
}
```

## Known issues

<a name="issues"></a>
Expand Down
1 change: 1 addition & 0 deletions packages/password/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/password/README.md",
"dependencies": {
"@inquirer/input": "^0.0.27-alpha.0",
"@inquirer/type": "^0.0.3-alpha.0",
"chalk": "^5.0.1"
},
"scripts": {
Expand Down
7 changes: 5 additions & 2 deletions packages/password/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { Prompt } from '@inquirer/type';
import input from '@inquirer/input';
import chalk from 'chalk';

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

export default (config: PasswordConfig, stdio?: Parameters<typeof input>[1]) => {
const password: Prompt<string, PasswordConfig> = (config, context) => {
if (config.transformer) {
throw new Error(
'Inquirer password prompt do not support custom transformer function. Use the input prompt instead.'
Expand All @@ -28,6 +29,8 @@ export default (config: PasswordConfig, stdio?: Parameters<typeof input>[1]) =>
return '';
},
},
stdio
context
);
};

export default password;
2 changes: 1 addition & 1 deletion packages/type/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type Context = {
export type Context = {
input?: NodeJS.ReadableStream;
output?: NodeJS.WritableStream;
clearPromptOnDone?: boolean;
Expand Down

0 comments on commit 27f4303

Please sign in to comment.