break things up, do some proper mediawiki API stuff to support editing

This commit is contained in:
ewin 2025-03-27 10:48:33 -04:00
parent 64eb4da894
commit e3af35a68e
Signed by: erin
SSH key fingerprint: SHA256:swjoHhREbZPbWe+gyJNi24d4NAxJSyUIm3fpZj4z3wc
4 changed files with 260 additions and 101 deletions

20
util.mjs Normal file
View file

@ -0,0 +1,20 @@
// misc helpers
import {execSync} from 'node:child_process';
/**
* terrible terrible terrible string diff helper for debugging
* @param {string} a
* @param {string} b
*/
export function diff (a, b) {
// base64 input strings before passing to shell to avoid escaping issues
// https://stackoverflow.com/a/60221847
// also use `|| true` to not throw an error when `diff` returns non-zero
execSync(`bash -c '
diff --color -u <(echo ${btoa(a)} | base64 -d) <(echo ${btoa(b)} | base64 -d)
' || true`, {
// display result directly in terminal
stdio: 'inherit',
});
}