UNPKG

projex

Version:
24 lines (23 loc) 747 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.promptConfirm = void 0; const prompts = 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 prompts([ { message, initial, type: "confirm", name: "response", onState }, ]); return response; }; exports.promptConfirm = promptConfirm;