import { formatTabs , formatCmd , formatNetwork , formatFile } from './formatters' ; export default function formatTree ( tree , events , buffer ) { if ( ! tree ) { return ; } const tabStr = formatTabs ( tree . level ) ; if ( tree . index !== - 1 ) { const processStr = formatCmd ( events [ tree . index ] ) ; buffer . push ( `${ tabStr }${ processStr }` ) ; } Object . keys ( tree . children ) . forEach ( kid => { formatTree ( tree . children [ kid ] , events , buffer ) ; } ) ; if ( tree . index !== - 1 ) { tree . network . map ( fIndex => { const fStr = formatNetwork ( events [ fIndex ] ) ; buffer . push ( `\t${ tabStr }${ fStr }` ) ; } ) ; tree . files . map ( fIndex => { const fStr = formatFile ( events [ fIndex ] ) ; buffer . push ( `\t${ tabStr }${ fStr }` ) ; } ) ; } }