Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
// node mut.mjs <file> <from> <to>: replace exactly one occurrence, else exit 3.
|
||||
import { readFileSync, writeFileSync } from 'node:fs';
|
||||
const [f, a, b] = process.argv.slice(2);
|
||||
const s = readFileSync(f, 'utf8'); const n = s.split(a).length - 1;
|
||||
if (n !== 1) { console.error(`matches=${n}`); process.exit(3); }
|
||||
writeFileSync(f, s.replace(a, () => b));
|
||||
Reference in New Issue
Block a user