1export function getDirFromFS(fsJSON: Record<string, string | null>, rootDir: string) { 2 return Object.entries(fsJSON) 3 .filter(([path, value]) => value !== null && path.startsWith(rootDir)) 4 .reduce<Record<string, string>>( 5 (acc, [path, fileContent]) => ({ 6 ...acc, 7 [path.substring(rootDir.length).startsWith('/') 8 ? path.substring(rootDir.length + 1) 9 : path.substring(rootDir.length)]: fileContent, 10 }), 11 {} 12 ); 13} 14