ffxiv-wiki-scripts/util.mjs

20 lines
579 B
JavaScript

// 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',
});
}