const fs = require('fs') const p = 'E:/SodiumPet/WorkPlace/v0.1.1/src/renderer/src/detail/Detail.tsx' let c = fs.readFileSync(p, 'utf8') const startMark = '
' const start = c.indexOf(startMark) if (start < 0) { console.log('legend not found') process.exit(1) } const end = c.indexOf('
', start) if (end < 0) { console.log('legend end not found') process.exit(1) } const oldBlock = c.slice(start, end + ' '.length) const newBlock = [ '
', ' {periodicZoneList(periodic).map((z) => (', ' ', ' ', ' {z.label}', ' ', ' ))}', '
' ].join('\n') c = c.replace(oldBlock, newBlock) if (!c.includes('periodicZoneList(periodic)')) { console.log('replace failed') process.exit(1) } c = c.replace(' periodicCellColor,', ' periodicCellColor,\n periodicZoneList,') fs.writeFileSync(p, c, 'utf8') console.log('detail legend patched')