public prompt()

in src/yo/yo/adapter.ts [40:72]


	public prompt(questions, callback) {
		let answers = {};
		callback = callback || function() {};

		const promise = questions.reduce((promise, question) => {
			return promise
				.then(() => {
					if (question.when === undefined) {
						return true;
					} else if (isFn(question.when)) {
						return runAsync(question.when)(answers);
					}

					return question.when;
				})
				.then(askQuestion => {
					if (askQuestion) {
						const prompt = PromptFactory.createPrompt(question, answers);

						return prompt.render().then(result => answers[question.name] = question.filter ? question.filter(result) : result);
					}
				});
		}, Promise.resolve());

		return promise
			.then(() => {
				this.outChannel.clear();
				this.outChannel.append(this.outBuffer);

				callback(answers);
				return answers;
			});
	}