UNPKG

@amplience/dc-cli

Version:
26 lines (25 loc) 862 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.asyncQuestion = asyncQuestion; const readline_1 = __importDefault(require("readline")); function asyncQuestionInternal(rl, question) { return new Promise((resolve) => { rl.question(question, resolve); }); } async function asyncQuestion(question, log) { const rl = readline_1.default.createInterface({ input: process.stdin, output: process.stdout, terminal: false }); const answer = await asyncQuestionInternal(rl, question); rl.close(); if (log != null) { log.appendLine(question + answer, true); } return answer.length > 0 && answer[0].toLowerCase() === 'y'; }