(content, target)
| 118 | } |
| 119 | |
| 120 | function inject(content, target) { |
| 121 | const s = content.indexOf(target.start); |
| 122 | const e = content.indexOf(target.end); |
| 123 | if (s < 0 || e < 0 || e < s) { |
| 124 | throw new Error(`${path.relative(ROOT, target.file)} 缺少 ${target.start} / ${target.end} 标记,无法注入数字段`); |
| 125 | } |
| 126 | return content.slice(0, s + target.start.length) + "\n" + target.block() + "\n" + content.slice(e); |
| 127 | } |
| 128 | |
| 129 | // 默认(无参):保持旧行为,打中文索引块到 stdout |
| 130 | if (!write && !check) { |