(output: string)
| 75 | |
| 76 | |
| 77 | export function parseSchtasksQuery(output: string): Record<string, string> | undefined { |
| 78 | |
| 79 | const lines = output.split(/\r?\n/).filter((line) => line.trim().length > 0); |
| 80 | if (lines.length < 2) return undefined; |
| 81 | |
| 82 | const header = parseCsvRow(lines[0] ?? ''); |
| 83 | const firstRow = parseCsvRow(lines[1] ?? ''); |
| 84 | if (header.length === 0 || firstRow.length === 0) return undefined; |
| 85 | |
| 86 | const out: Record<string, string> = {}; |
| 87 | for (let i = 0; i < header.length; i += 1) { |
| 88 | const key = header[i] ?? ''; |
| 89 | const value = firstRow[i] ?? ''; |
| 90 | if (key.length > 0) { |
| 91 | out[key] = value; |
| 92 | } |
| 93 | } |
| 94 | return out; |
| 95 | } |
| 96 | |
| 97 | |
| 98 | function parseCsvRow(line: string): string[] { |
no test coverage detected