UNPKG

cli-block

Version:
48 lines (46 loc) 1.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.blockLine = exports.createBlockLine = void 0; const border_1 = require("../border"); const settings_1 = require("../settings"); const util_1 = require("../util"); const createBlockLine = (msg = null, settings = {}) => { const cfg = (0, settings_1.useSettings)(settings); let lines = []; if (msg !== null) { if (typeof msg == "string") msg = (0, util_1.breakText)(msg, (0, settings_1.getContentWidth)(cfg)); if (Array.isArray(msg)) { msg.forEach((txt, i) => { txt = i == 0 ? `${cfg.prefix ? cfg.prefix + " " : ""}${txt}` : `${cfg.prefix ? (0, util_1.spaces)((0, util_1.strWidth)(cfg.prefix)) + " " : ""}${txt}`; lines.push((0, util_1.spaces)(cfg.indentBlock) + (0, border_1.border)(border_1.BorderElement.side, cfg) + (0, util_1.spaces)((0, settings_1.getPadding)(cfg)) + (0, util_1.spacedText)((0, settings_1.getContentWidth)(cfg), txt) + (0, util_1.spaces)((0, settings_1.getPadding)(cfg)) + (0, border_1.border)(border_1.BorderElement.side, cfg)); }); } } else { lines = [ `${(0, util_1.spaces)(cfg.indentBlock)}${(0, border_1.border)(border_1.BorderElement.side, cfg)}${(0, util_1.spaces)((0, settings_1.getFrameWidth)(cfg))}${(0, border_1.border)(border_1.BorderElement.side, cfg)}`, ]; } return lines; }; exports.createBlockLine = createBlockLine; /* BLOCK LINE */ const blockLine = (msg = null, settings = {}) => { const lines = (0, exports.createBlockLine)(msg, settings); lines.forEach((txt) => { (0, util_1.logger)(txt, settings); }); }; exports.blockLine = blockLine; //# sourceMappingURL=blocks.line.js.map