fix(core): update

This commit is contained in:
2020-02-02 13:45:59 +00:00
parent cfdd54eff1
commit 97c3ccb329
7 changed files with 744 additions and 759 deletions

View File

@ -0,0 +1,33 @@
import * as plugins from './smartinteract.plugins';
import { IAnswerObject } from './smartinteract.classes.smartinteract';
/**
* class AnswerBucket holds answers
*/
export class AnswerBucket {
answerMap = new plugins.lik.Objectmap<IAnswerObject>();
/**
* add an answer to the bucket
*/
addAnswer(answerArg: IAnswerObject) {
this.answerMap.add(answerArg);
}
/**
* gets an answer for a specific name
*/
getAnswerFor(nameArg: string) {
let answer = this.answerMap.find(answerArg => {
return answerArg.name === nameArg;
});
return answer ? answer.value : null;
}
/**
* gets all answers as array
*/
getAllAnswers() {
return this.answerMap.getArray();
}
}

View File

@ -1,6 +1,6 @@
import * as plugins from './smartinteract.plugins';
import * as smartpromise from '@pushrocks/smartpromise';
import { Objectmap } from '@pushrocks/lik';
import { AnswerBucket } from './smartinteract.classes.answerbucket';
/**
* the availeable question types
@ -48,7 +48,7 @@ export class SmartInteract {
/**
* holds the qestion queue, that is emptied once you call
*/
private questionMap = new Objectmap<IQuestionObject>();
private questionMap = new plugins.lik.Objectmap<IQuestionObject>();
/**
* constructor of class SmartInteract
@ -76,13 +76,9 @@ export class SmartInteract {
validate: optionsArg.validate
}
])
.then((answers: IAnswerObject[]) => {
.then((answers) => {
// adjust to the fact that now dots define paths for inquirer
let answerValue: any = answers;
let nameArray = optionsArg.name.split('.');
for (let name of nameArray) {
answerValue = answerValue[name];
}
let answerValue = plugins.smartparam.smartGet(answers, optionsArg.name);
done.resolve({
name: optionsArg.name,
value: answerValue
@ -140,34 +136,3 @@ export class SmartInteract {
}
}
}
/**
* class AnswerBucket holds answers
*/
export class AnswerBucket {
answerMap = new Objectmap<IAnswerObject>();
/**
* add an answer to the bucket
*/
addAnswer(answerArg: IAnswerObject) {
this.answerMap.add(answerArg);
}
/**
* gets an answer for a specific name
*/
getAnswerFor(nameArg: string) {
let answer = this.answerMap.find(answerArg => {
return answerArg.name === nameArg;
});
return answer.value;
}
/**
* gets all answers as array
*/
getAllAnswers() {
return this.answerMap.getArray();
}
}

View File

@ -1,3 +1,14 @@
// pushrocks scope
import * as lik from '@pushrocks/lik';
import * as smartparam from '@pushrocks/smartparam';
export {
lik,
smartparam
}
// third party scope
import * as inquirer from 'inquirer';
export { inquirer };