UNPKG

eas-cli

Version:
17 lines (16 loc) 708 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const chalk_1 = tslib_1.__importDefault(require("chalk")); function formatFields(fields, options = { labelFormat: chalk_1.default.dim }) { const columnWidth = fields.reduce((a, b) => (a.label.length > b.label.length ? a : b)).label .length; return fields .map(({ label, value }) => { // make all labels fixed-width const formattedLabel = options.labelFormat(label.length < columnWidth ? `${label}${' '.repeat(columnWidth - label.length)}` : label); return `${formattedLabel} ${value}`; }) .join('\n'); } exports.default = formatFields;