| 102 | } |
| 103 | |
| 104 | function reportFirstDiff(branchNdjson: string, mainNdjson: string): void { |
| 105 | const bl = fs.readFileSync(branchNdjson, 'utf8').split('\n'); |
| 106 | const ml = fs.readFileSync(mainNdjson, 'utf8').split('\n'); |
| 107 | const n = Math.max(bl.length, ml.length); |
| 108 | for (let i = 0; i < n; i++) { |
| 109 | if (bl[i] !== ml[i]) { |
| 110 | const cut = (s: string | undefined): string => (s === undefined ? '<missing>' : s.slice(0, 400)); |
| 111 | // eslint-disable-next-line no-console |
| 112 | console.log(`\nFirst difference at line ${i + 1}:`); |
| 113 | // eslint-disable-next-line no-console |
| 114 | console.log(` branch: ${cut(bl[i])}`); |
| 115 | // eslint-disable-next-line no-console |
| 116 | console.log(` main: ${cut(ml[i])}`); |
| 117 | break; |
| 118 | } |
| 119 | } |
| 120 | // eslint-disable-next-line no-console |
| 121 | console.log(`\n(branch lines=${bl.length}, main lines=${ml.length})`); |
| 122 | } |
| 123 | |
| 124 | async function run(): Promise<void> { |
| 125 | fs.mkdirSync(outDir, { recursive: true }); |