( output: string | ((data: any, result: any) => void) | null, outputFormats: string[] | null, data: any, result: any, fnName: string )
| 29 | } |
| 30 | |
| 31 | function writeOutput( |
| 32 | output: string | ((data: any, result: any) => void) | null, |
| 33 | outputFormats: string[] | null, |
| 34 | data: any, |
| 35 | result: any, |
| 36 | fnName: string |
| 37 | ) { |
| 38 | const writtenFilenames: string[] = []; |
| 39 | |
| 40 | if (isNullish(output)) { |
| 41 | return result; |
| 42 | } |
| 43 | if (typeof output === 'function') { |
| 44 | output(data, result); |
| 45 | } else { |
| 46 | outputFormats = outputFormats || [Formats.JSON]; |
| 47 | |
| 48 | const defaultFilename = output === 'default' ? fnName : output; |
| 49 | |
| 50 | for (const fm of outputFormats) { |
| 51 | if (fm === Formats.JSON) { |
| 52 | // @ts-ignore |
| 53 | const filename = fixJsonFilename(defaultFilename); |
| 54 | writtenFilenames.push(filename); |
| 55 | writeJson(result, filename, false); |
| 56 | } else if (fm === Formats.CSV) { |
| 57 | // @ts-ignore |
| 58 | const filename = fixCsvFilename(defaultFilename); |
| 59 | writtenFilenames.push(filename); |
| 60 | writeCsv(result, filename, false); |
| 61 | } else if (fm === Formats.EXCEL) { |
| 62 | // @ts-ignore |
| 63 | const filename = fixExcelFilename(defaultFilename); |
| 64 | writtenFilenames.push(filename); |
| 65 | writeExcel(result, filename, false); |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | printFilenames(writtenFilenames); |
| 71 | } |
| 72 | |
| 73 | function cleanErrorLogs(errorLogsDir: string, sortKey: (folder: string) => Date) { |
| 74 | const folders = fs.readdirSync(errorLogsDir); |
no test coverage detected