21 lines
884 B
JavaScript
21 lines
884 B
JavaScript
// Collapses every run of 2+ literal backslashes to one in the gitea source files (over-escaped writes).
|
|
import fs from 'node:fs'
|
|
const B = String.fromCharCode(92)
|
|
const files = ['gitea-api.ts', 'gitea.ts', 'gitea-trigger.ts', 'gitea-channel.ts']
|
|
for (const f of files) {
|
|
const path = 'src/sources/' + f
|
|
const before = fs.readFileSync(path, 'utf8')
|
|
let after = before
|
|
while (after.includes(B + B)) after = after.split(B + B).join(B)
|
|
if (after !== before) {
|
|
fs.writeFileSync(path, after)
|
|
console.log(f, 'collapsed', (before.length - after.length), 'bytes')
|
|
} else console.log(f, 'clean')
|
|
}
|
|
for (const f of files) {
|
|
const t = fs.readFileSync('src/sources/' + f, 'utf8')
|
|
const remaining = t.split(B + B).length - 1
|
|
const quotes = t.split(B + String.fromCharCode(39)).length - 1
|
|
console.log(f, 'remaining double:', remaining, 'escaped-quote sites:', quotes)
|
|
}
|