Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
submitAnswer(submitMulti: boolean = false) {
const answer = this.opt.multi && submitMulti ?
this.paths :
this.autocomplete.getPath().getAbsolutePath();
const validate = runAsync(this.opt.validate);
const filter = runAsync(this.opt.filter);
let promiseChain = validate(answer, this.answers, this.opt.multi ? this.paths : null)
.then((isValid) => {
if (isValid !== true) {
throw isValid;
}
return answer;
})
.then(filter);
if (!this.opt.multi) {
// Render the final path
promiseChain = promiseChain.then((finalAnswer) => {
this.renderer.render(finalAnswer);
return finalAnswer;
});
submitAnswer(submitMulti: boolean = false) {
const answer = this.opt.multi && submitMulti ?
this.paths :
this.autocomplete.getPath().getAbsolutePath();
const validate = runAsync(this.opt.validate);
const filter = runAsync(this.opt.filter);
let promiseChain = validate(answer, this.answers, this.opt.multi ? this.paths : null)
.then((isValid) => {
if (isValid !== true) {
throw isValid;
}
return answer;
})
.then(filter);
if (!this.opt.multi) {
// Render the final path
promiseChain = promiseChain.then((finalAnswer) => {
this.renderer.render(finalAnswer);
return finalAnswer;