UNPKG

xweb-templating

Version:

A cli tool for converting 'tags' to regular html, php or some other format

57 lines (56 loc) 2.25 kB
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()); }); }; import chalk from "chalk"; import inquirer from "inquirer"; export function confirm(argv, message) { return __awaiter(this, void 0, void 0, function* () { if (argv.yes) return true; const CONFIRM = yield inquirer.prompt([{ name: "ok", message, type: "list", choices: ["yes", "no"], default: "yes" }]); return CONFIRM.ok == "yes"; }); } export function info(executer, message) { console.info(`[${chalk.green(executer)}] ${chalk.blue("info")}: ${message}`); } export function large_info(executer, title, message) { let actual_text = `[${chalk.green(executer)}] ${chalk.blue("info")}: ${title}\n`; actual_text += message .replaceAll("\r", "") .split("\n") .map((line) => chalk.magenta("> ") + line).join("\n"); console.log(actual_text); } export function status(executer, message) { console.info(`[${chalk.green(executer)}] ${chalk.cyan("status")}: ${message}`); } export function warn(executer, message, no_confirm) { return __awaiter(this, void 0, void 0, function* () { console.info(`[${chalk.green(executer)}] ${chalk.yellow("warn")}: ${message}`); if (no_confirm) return; const STOP = !(yield confirm({ y: no_confirm, _: [], $0: "" }, "Continue?")); if (STOP) process.exit(0); }); } export function error(executer, message) { throw new Error(`[${executer}] error: ${message}`); }