import { Contents } from '../shared/fileDirectory' ; const getFileContents = ( path , fileName , cwdContents ) : Contents => { let root = cwdContents ; for ( let i = 0 ; i < path . length ; i ++ ) { const current = path [ i ] || '/' ; if ( typeof root !== 'string' ) { const f = root ?. [ current ] ?. contents ?. [ fileName ] ; if ( f && f ?. fileType !== 'directory' ) { return root ?. [ current ] ?. contents ?. [ fileName ] ?. contents as string ; } root = root ?. [ current ] ?. contents ; } } return root ; } ; export default getFileContents ;