Skip to content

Commit 45f81e9

Browse files
authored
fix: prefer output.pdf when selecting compile PDF (#26) (#27)
Overleaf's CLSI always names the main compile output 'output.pdf'. The previous find(f => f.type === 'pdf') could match figure PDFs or *-eps-converted-to.pdf intermediates that appear earlier in the array. Now explicitly matches path === 'output.pdf' first, with a fallback to type === 'pdf' for non-standard CLSI responses. Fixes #26
1 parent 881ceef commit 45f81e9

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aloth/olcli",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"description": "Command-line interface for Overleaf — Sync, manage, and compile LaTeX projects from your terminal",
55
"type": "module",
66
"bin": {

src/client.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,11 @@ export class OverleafClient {
697697
throw new Error(`Compilation failed: ${data.status}`);
698698
}
699699

700-
const pdfFile = data.outputFiles?.find((f: any) => f.type === 'pdf');
700+
// Match by path 'output.pdf' — Overleaf's CLSI always names the main
701+
// compile output 'output.pdf'. Matching only on type === 'pdf' can pick up
702+
// figure PDFs or *-eps-converted-to.pdf intermediates. See #26.
703+
const pdfFile = data.outputFiles?.find((f: any) => f.path === 'output.pdf')
704+
|| data.outputFiles?.find((f: any) => f.type === 'pdf');
701705
if (!pdfFile) {
702706
throw new Error('No PDF output found');
703707
}
@@ -2059,7 +2063,10 @@ export class OverleafClient {
20592063
this.applySetCookieHeaders(response.headers['set-cookie'] as string[] | undefined);
20602064

20612065
const data = response.body as any;
2062-
const pdfFile = data.outputFiles?.find((f: any) => f.type === 'pdf');
2066+
// Prefer 'output.pdf' (the main compile output) over any other PDF.
2067+
// See #26 — projects with figure PDFs could return the wrong file.
2068+
const pdfFile = data.outputFiles?.find((f: any) => f.path === 'output.pdf')
2069+
|| data.outputFiles?.find((f: any) => f.type === 'pdf');
20632070

20642071
// Overleaf's CDN requires ?clsiserverid=<id> for build-output downloads.
20652072
// Without it every output (pdf/log/bbl/...) 404s. See issue #22.

0 commit comments

Comments
 (0)