.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / enquirer / lib / types / auth.js
1 'use strict';
2
3 const FormPrompt = require('../prompts/form');
4
5 const defaultAuthenticate = () => {
6   throw new Error('expected prompt to have a custom authenticate method');
7 };
8
9 const factory = (authenticate = defaultAuthenticate) => {
10
11   class AuthPrompt extends FormPrompt {
12     constructor(options) {
13       super(options);
14     }
15
16     async submit() {
17       this.value = await authenticate.call(this, this.values, this.state);
18       super.base.submit.call(this);
19     }
20
21     static create(authenticate) {
22       return factory(authenticate);
23     }
24   }
25
26   return AuthPrompt;
27 };
28
29 module.exports = factory();