UNPKG

vils

Version:

Recursively outputs file paths and contents in various formats

12 lines (10 loc) 411 B
import { IFormatter } from './Formatter'; import { FileEntry } from '../walker'; export class JsonFormatter implements IFormatter { format(entries: FileEntry[]): string { return JSON.stringify(entries.map(e => ({ path: e.relativePath, content: typeof e.content === 'string' ? e.content : `<vils unable to read: ${e.content.error}>` })), null, 2); } }