UNPKG

vils

Version:

Recursively outputs file paths and contents in various formats

15 lines (13 loc) 530 B
import { IFormatter } from './Formatter'; import { FileEntry } from '../walker'; export class MarkdownFormatter implements IFormatter { format(entries: FileEntry[]): string { return entries.map(e => { if (typeof e.content === 'string') { return `# ${e.relativePath}\n\n\`\`\`\n${e.content}\n\`\`\``; } else { return `# ${e.relativePath}\n\n\`\`\`\n<vils unable to read: ${e.content.error}>\n\`\`\``; } }).join('\n\n'); } }