From cc621d6d643b884a4ee71ad16bd82218d8cd338a Mon Sep 17 00:00:00 2001 From: lee <274153705@qq.com> Date: Mon, 18 Jul 2022 13:59:28 +0800 Subject: [PATCH] Support custom questions change ``` const question = creators[name].createQuestion(state); ``` to ``` const question = name.createQuestion ? name.createQuestion(state):creators[name].createQuestion(state); ``` and then support custom question to override the default question ``` module.exports = { ... questions: [ { createQuestion: (state) => { return { message: "custom scope question:", name: "scope", type: "input" }; } }, ... ], }; ``` --- lib/createQuestions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/createQuestions.js b/lib/createQuestions.js index 510bc4a2..e15ca873 100644 --- a/lib/createQuestions.js +++ b/lib/createQuestions.js @@ -21,7 +21,7 @@ const createQuestions = (state, cliAnswers) => { const questions = state.config.questions .filter((name) => cliAnswers[name] === undefined) .map((name) => { - const question = creators[name].createQuestion(state); + const question = name.createQuestion ? name.createQuestion(state):creators[name].createQuestion(state); if (state.config.messages && state.config.messages[name]) { question.message = state.config.messages[name];