inquirer#DistinctQuestion TypeScript Examples
The following examples show how to use
inquirer#DistinctQuestion.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts From plasmic with MIT License | 6 votes |
/**
* Prompt the user for any answers that we're missing from the command-line args
* @param question instance of a question formatted for `inquirer`
* @returns
*/
async function maybePrompt(question: DistinctQuestion) {
const name = ensure(question.name) as string;
const message = ensure(question.message);
const maybeAnswer = argv[name];
if (maybeAnswer === null || maybeAnswer === undefined || maybeAnswer === "") {
const ans = await inquirer.prompt({ ...question });
return ans[name];
} else {
console.log(`${message}: ${maybeAnswer} (specified in CLI arg)`);
return ensure(argv[name]);
}
}