( filePath: string, headers: string[], rows: string[][] )
| 863 | } |
| 864 | |
| 865 | const writeToCsv = ( |
| 866 | filePath: string, |
| 867 | headers: string[], |
| 868 | rows: string[][] |
| 869 | ): void => { |
| 870 | const content = [ |
| 871 | headers.join(","), |
| 872 | ...rows.map(row => row.map(escapeForCsv).join(",")) |
| 873 | ].join("\n") |
| 874 | writeFile(filePath, content) |
| 875 | } |
| 876 | |
| 877 | const escapeForCsv = (value: string): string => { |
| 878 | if (value.includes(",") || value.includes('"') || value.includes("\n")) |
no test coverage detected