UNPKG

agentsqripts

Version:

Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems

33 lines (28 loc) 948 B
/** * @file Format file list utility * @description Single responsibility: Format file lists with truncation */ /** * Format file list with truncation * @param {Array} files - Array of file paths * @param {number} maxShow - Maximum files to show (default: 10) * @param {string} indent - Indentation string (default: ' ') * @param {Function} formatter - Optional formatter for each file * @returns {string} Formatted file list */ function formatFileList(files, maxShow = 10, indent = ' ', formatter = null) { let output = ''; const filesToShow = Math.min(files.length, maxShow); for (let i = 0; i < filesToShow; i++) { if (formatter) { output += `${indent}${formatter(files[i])}\n`; } else { output += `${indent}${files[i]}\n`; } } if (files.length > maxShow) { output += `${indent}... and ${files.length - maxShow} more files\n`; } return output; } module.exports = formatFileList;