Skip to content

Commit

Permalink
fix: unknown features should checked against all possible features
Browse files Browse the repository at this point in the history
  • Loading branch information
3cp committed Jun 13, 2022
1 parent 3e75706 commit 40d8732
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions lib/run-questionnaire.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,20 @@ async function run(questions, {
}
}

const allPossibleFeatures = [];
for (let i = 0, ii = questions.length; i < ii; i++) {
await ask(questions[i]);
const q = questions[i];
if (q.choices) {
q.choices.forEach(choice => {
if (choice.value) {
allPossibleFeatures.push(choice.value);
}
});
}
await ask(q);
}

const unknownFeatures = minusSet(preselectedFeatures, pickedFeatures);
const unknownFeatures = minusSet(preselectedFeatures, allPossibleFeatures);

return [
{...predefinedProperties, ...properties},
Expand Down
2 changes: 1 addition & 1 deletion test/run-questionnaire.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ test('run runs through questionnaire with preselectedFeatures and predefinedProp

test('run runs through questionnaire with preselectedFeatures and predefinedProperties, and keeps unknown properties and selection', async t => {
const result = await run(questions, {
preselectedFeatures: ['postcss', 'lorem', 'abc', 'lorem'],
preselectedFeatures: ['webpack', 'dumber', 'postcss', 'lorem', 'abc', 'lorem'],
predefinedProperties: {name: 'new-app', foo: 'bar'},
_debug: [2]
});
Expand Down

0 comments on commit 40d8732

Please sign in to comment.