password.js 432 B

123456789101112131415161718
  1. 'use strict';
  2. const StringPrompt = require('../types/string');
  3. class PasswordPrompt extends StringPrompt {
  4. constructor(options) {
  5. super(options);
  6. this.cursorShow();
  7. }
  8. format(input = this.input) {
  9. if (!this.keypressed) return '';
  10. let color = this.state.submitted ? this.styles.primary : this.styles.muted;
  11. return color(this.symbols.asterisk.repeat(input.length));
  12. }
  13. }
  14. module.exports = PasswordPrompt;