(path: string)
| 66 | } |
| 67 | |
| 68 | function cleanFile(path: string): { dirty: boolean; counts: Map<string, number> } { |
| 69 | const counts = new Map<string, number>() |
| 70 | const raw = readFileSync(path, 'utf8') |
| 71 | const data: CommitFile = JSON.parse(raw) |
| 72 | let dirty = false |
| 73 | |
| 74 | for (const commit of data.commits ?? []) { |
| 75 | for (const op of commit.operations ?? []) { |
| 76 | if (cleanOrderObject(op.order, counts)) dirty = true |
| 77 | if (cleanOrderObject(op.changes, counts)) dirty = true |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | if (dirty) { |
| 82 | const serialised = JSON.stringify(data, null, 2) + '\n' |
| 83 | const tmp = path + '.tmp' |
| 84 | writeFileSync(tmp, serialised, 'utf8') |
| 85 | renameSync(tmp, path) |
| 86 | } |
| 87 | return { dirty, counts } |
| 88 | } |
| 89 | |
| 90 | function main() { |
| 91 | let totalFiles = 0 |
no test coverage detected