UNPKG

vtex

Version:

The platform for e-commerce apps

23 lines (22 loc) 808 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.promptConfirm = void 0; const tslib_1 = require("tslib"); const prompts_1 = tslib_1.__importDefault(require("prompts")); const enableTerminalCursor = () => { process.stdout.write('\x1B[?25h'); }; const onState = (state) => { if (state.aborted) { // If we don't re-enable the terminal cursor before exiting // the program, the cursor will remain hidden enableTerminalCursor(); process.stdout.write('\n'); process.exit(1); } }; const promptConfirm = async (message, initial = true) => { const { response } = await (0, prompts_1.default)([{ message, initial, type: 'confirm', name: 'response', onState }]); return response; }; exports.promptConfirm = promptConfirm;