Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/enquirer/prompt-password

This repository has been archived, use the built-in password prompt in Enquirer instead.
https://github.com/enquirer/prompt-password

enquirer mask password plugin prompt zxcvbn

Last synced: 6 days ago
JSON representation

This repository has been archived, use the built-in password prompt in Enquirer instead.

Awesome Lists containing this project

README

        

# prompt-password [![NPM version](https://img.shields.io/npm/v/prompt-password.svg?style=flat)](https://www.npmjs.com/package/prompt-password) [![NPM monthly downloads](https://img.shields.io/npm/dm/prompt-password.svg?style=flat)](https://npmjs.org/package/prompt-password) [![NPM total downloads](https://img.shields.io/npm/dt/prompt-password.svg?style=flat)](https://npmjs.org/package/prompt-password) [![Linux Build Status](https://img.shields.io/travis/enquirer/prompt-password.svg?style=flat&label=Travis)](https://travis-ci.org/enquirer/prompt-password)

> Password prompt. Can be used as a standalone prompt, or as a plugin for [Enquirer](http://enquirer.io).

![prompt-password example](https://raw.githubusercontent.com/enquirer/prompt-password/master/docs/example.gif)

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install --save prompt-password
```

## Usage

```js
var Prompt = require('..');
var prompt = new Prompt({
type: 'password',
message: 'Enter your password please',
name: 'password'
});

prompt.run()
.then(function(answers) {
console.log(answers)
});
```

### mask function

Use [prompt-password-strength](https://github.com/enquirer/prompt-password-strength), or pass a function to customize how the input is masked:

```js
var Prompt = require('..');
var prompt = new Prompt({
type: 'password',
message: 'Enter your password please',
name: 'password',
mask: function(input) {
return '█' + new Array(String(input).length).join('█');
}
});

prompt.run()
.then(function(answers) {
console.log(answers)
});
```

## Enquirer usage

Use the `.register` method to add the "password" prompt type to [enquirer](http://enquirer.io):

```js
var Enquirer = require('enquirer');
var enquirer = new Enquirer();

enquirer.register('password', require('prompt-password'));

// questions can be an array or object
var questions = {
type: 'password',
message: 'Enter your password please',
name: 'password'
};

enquirer.ask(questions)
.then(function(answers) {
console.log(answers)
});
```

## Attribution

Based on the `password` prompt in inquirer.

## About

### Related projects

* [enquirer](https://www.npmjs.com/package/enquirer): Intuitive, plugin-based prompt system for node.js. | [homepage](http://enquirer.io "Intuitive, plugin-based prompt system for node.js.")
* [prompt-base](https://www.npmjs.com/package/prompt-base): Base prompt module used for creating custom prompts. | [homepage](https://github.com/enquirer/prompt-base "Base prompt module used for creating custom prompts.")
* [prompt-question](https://www.npmjs.com/package/prompt-question): Question object, used by Enquirer and prompt plugins. | [homepage](https://github.com/enquirer/prompt-question "Question object, used by Enquirer and prompt plugins.")

### Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).

### Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

```sh
$ npm install && npm test
```

### Author

**Jon Schlinkert**

* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)

### License

Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).

***

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on June 05, 2017._