Fix QuartoRunner mv: use relative paths to avoid $COMPILE_DIR replacement bug
Build and Deploy Verso / deploy (push) Successful in 11m1s

LocalCommandRunner.replace() uses String.replace() which only substitutes
the FIRST occurrence of '$COMPILE_DIR' in the shell script string. The mv
commands had two more occurrences that stayed as literal '$COMPILE_DIR',
which the shell expanded to '', making 'mv /main.pdf /output.pdf' fail
silently. The file was produced (Quarto logged 'Output created: main.pdf')
but never renamed to output.pdf, so the pipeline reported failure.

Fix: mv uses relative filenames since the shell CWD is already the compile
directory (set by LocalCommandRunner via the spawnCwd option).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
claude
2026-05-31 15:51:01 +00:00
parent 48fd24a6b2
commit 090018c191
+5 -4
View File
@@ -59,12 +59,13 @@ function _buildQuartoCommand(mainFile) {
// expected by the rest of the pipeline.
const inputPath = `$COMPILE_DIR/${mainFile}`
const baseName = mainFile.replace(/\.[^/.]+$/, '') // strip extension
const pdfOut = `$COMPILE_DIR/${baseName}.pdf`
const htmlOut = `$COMPILE_DIR/${baseName}.html`
// LocalCommandRunner.replace() only replaces the FIRST $COMPILE_DIR
// occurrence in the shell string, so the mv commands use relative paths
// instead — the shell CWD is already set to the compile directory.
const cmd =
`quarto render ${inputPath} --embed-resources 2>&1 && ` +
`(mv ${pdfOut} $COMPILE_DIR/output.pdf 2>/dev/null || ` +
`mv ${htmlOut} $COMPILE_DIR/output.html 2>/dev/null)`
`(mv ${baseName}.pdf output.pdf 2>/dev/null || ` +
`mv ${baseName}.html output.html 2>/dev/null)`
return ['/bin/sh', '-c', cmd]
}