UNPKG

@capawesome/cli

Version:

The Capawesome Cloud Command Line Interface (CLI) to manage Live Updates and more.

41 lines (40 loc) 1.88 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.passwordPrompt = exports.prompt = void 0; const prompts_1 = require("@clack/prompts"); const consola_1 = __importDefault(require("consola")); const prompt = (message, options) => __awaiter(void 0, void 0, void 0, function* () { options = Object.assign(Object.assign({}, (options || {})), { cancel: 'symbol' }); const response = yield consola_1.default.prompt(message, options); // See https://github.com/unjs/consola/pull/325#issue-2751614453 if (response === Symbol.for('cancel')) { process.exit(0); } return response; }); exports.prompt = prompt; /** * This is a workaround to support password prompts. * * @see https://github.com/unjs/consola/issues/285 */ const passwordPrompt = (message) => __awaiter(void 0, void 0, void 0, function* () { const result = yield (0, prompts_1.password)({ message }); if (typeof result === 'symbol') { process.exit(0); } return result; }); exports.passwordPrompt = passwordPrompt;