Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
[expo-cli] check when field when prompting in noninteractive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
wkozyra95 committed Jul 24, 2020
1 parent 375ebff commit b240a01
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/expo-cli/src/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,22 @@ export default function prompt(
questions: CliQuestions,
{ nonInteractiveHelp }: { nonInteractiveHelp?: string } = {}
) {
const nQuestions = Array.isArray(questions) ? questions.length : 1;
if (program.nonInteractive && nQuestions !== 0) {
questions = Array.isArray(questions) ? questions : [questions];
const nQuestions = questions.length;
if (program.nonInteractive) {
const isAllWhenFalse =
questions.filter(question => {
if (!('when' in question)) {
return true;
} else if (typeof question.when === 'function') {
return question.when({});
} else {
return question.when;
}
}).length === 0;
if (nQuestions === 0 || isAllWhenFalse) {
return {} as any;
}
let message = `Input is required, but Expo CLI is in non-interactive mode.\n`;
if (nonInteractiveHelp) {
message += nonInteractiveHelp;
Expand Down

0 comments on commit b240a01

Please sign in to comment.