(items: TreeItem[], options?: TreeOptions)
| 58 | * @returns {string} The formatted tree as a string, ready for printing to the console or elsewhere. |
| 59 | */ |
| 60 | export function formatTree(items: TreeItem[], options?: TreeOptions): string { |
| 61 | options = { |
| 62 | prefix: " ", |
| 63 | ellipsis: "...", |
| 64 | ...options, |
| 65 | }; |
| 66 | |
| 67 | const tree = _buildTree(items, options).join(""); |
| 68 | if (options && options.color) { |
| 69 | return colorize(options.color, tree); |
| 70 | } |
| 71 | |
| 72 | return tree; |
| 73 | } |
| 74 | |
| 75 | function _buildTree(items: TreeItem[], options?: TreeOptions): string[] { |
| 76 | const chunks: string[] = []; |
no test coverage detected
searching dependent graphs…