fix(writing-skills): run graphviz without a shell in render-graphs.js

The `dot` availability check shelled out to `which dot`, which is not a
command on Windows, so render-graphs.js reported graphviz as missing on
Windows even when it was installed. Replace it with a direct `dot -V`
probe via execFileSync.

Also switch the SVG render call from execSync to execFileSync('dot',
['-Tsvg']). Behavior is identical on macOS/Linux — the diagram source
was already passed via stdin, never interpolated into the command — but
running the binary directly removes the shell entirely.
This commit is contained in:
Jesse Vincent
2026-06-18 15:15:54 -07:00
parent 81f860a993
commit ffc29fa077

View File

@@ -15,7 +15,7 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const { execSync } = require('child_process'); const { execFileSync } = require('child_process');
function extractDotBlocks(markdown) { function extractDotBlocks(markdown) {
const blocks = []; const blocks = [];
@@ -69,7 +69,7 @@ ${bodies.join('\n\n')}
function renderToSvg(dotContent) { function renderToSvg(dotContent) {
try { try {
return execSync('dot -Tsvg', { return execFileSync('dot', ['-Tsvg'], {
input: dotContent, input: dotContent,
encoding: 'utf-8', encoding: 'utf-8',
maxBuffer: 10 * 1024 * 1024 maxBuffer: 10 * 1024 * 1024
@@ -107,9 +107,10 @@ function main() {
process.exit(1); process.exit(1);
} }
// Check if dot is available // Check if dot is available. Run the binary directly rather than probing
// with `which`, which is not a command on Windows.
try { try {
execSync('which dot', { encoding: 'utf-8' }); execFileSync('dot', ['-V'], { stdio: 'ignore' });
} catch { } catch {
console.error('Error: graphviz (dot) not found. Install with:'); console.error('Error: graphviz (dot) not found. Install with:');
console.error(' brew install graphviz # macOS'); console.error(' brew install graphviz # macOS');