fallout-utility
Version:
<h1 align="center"> fallout-utility <br> </h1>
29 lines • 997 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.input = void 0;
/**
* Prompts the user for input
* @deprecated Use something like `inquirer` package instead
*/
function input(prompt = '') {
if (typeof prompt === 'string') {
prompt = { text: prompt };
}
const Prompt = require('prompt-sync')({
sigint: prompt.sigint || true,
eof: prompt.eot || true,
});
const text = prompt?.text || '';
const echo = prompt?.echo || null;
const repeatIfEmpty = prompt?.repeatIfEmpty || prompt?.repeat || false;
const exitStrings = prompt?.exitStrings || [];
let response;
while (true) {
response = Prompt(text, (echo === null ? null : { echo: echo })) || '';
if (response || !response && !repeatIfEmpty || exitStrings && exitStrings.includes(response))
break;
}
return exitStrings.includes(response) ? null : response;
}
exports.input = input;
//# sourceMappingURL=cli.js.map