Files
SnowLuma/.pnpm-store/v11/files/c5/2205e7e33311caaf3ff4722ac586a6d88b83fb2b820d78064664c24d8cc430323b189a2599dc9f298a9b3ddf591304b8a01921d8567834f9119c0d185894ce
TanTan 2a69b23b47
Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Skipped
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

65 lines
1.8 KiB
Plaintext

'use strict';
const box = require('./shared/consola.DwRq1yyg.cjs');
require('node:tty');
function formatTree(items, options) {
options = {
prefix: " ",
ellipsis: "...",
...options
};
const tree = _buildTree(items, options).join("");
if (options && options.color) {
return box.colorize(options.color, tree);
}
return tree;
}
function _buildTree(items, options) {
const chunks = [];
const total = items.length - 1;
for (let i = 0; i <= total; i++) {
const item = items[i];
const isItemString = typeof item === "string";
const isLimit = options?.maxDepth != null && options.maxDepth <= 0;
if (isLimit) {
const ellipsis = `${options.prefix}${options.ellipsis}
`;
return [
isItemString ? ellipsis : item.color ? box.colorize(item.color, ellipsis) : ellipsis
// prettier-ignore
];
}
const isLast = i === total;
const prefix = isLast ? `${options?.prefix}\u2514\u2500` : `${options?.prefix}\u251C\u2500`;
if (isItemString) {
chunks.push(`${prefix}${item}
`);
} else {
const log = `${prefix}${item.text}
`;
chunks.push(item.color ? box.colorize(item.color, log) : log);
if (item.children) {
const _tree = _buildTree(item.children, {
...options,
maxDepth: options?.maxDepth == null ? void 0 : options.maxDepth - 1,
prefix: `${options?.prefix}${isLast ? " " : "\u2502 "}`
});
chunks.push(..._tree);
}
}
}
return chunks;
}
exports.align = box.align;
exports.box = box.box;
exports.centerAlign = box.centerAlign;
exports.colorize = box.colorize;
exports.colors = box.colors;
exports.getColor = box.getColor;
exports.leftAlign = box.leftAlign;
exports.rightAlign = box.rightAlign;
exports.stripAnsi = box.stripAnsi;
exports.formatTree = formatTree;