feat: support compiling a specific tex file as the root document - #38
Open
SomeBottle wants to merge 7 commits into
Open
feat: support compiling a specific tex file as the root document#38SomeBottle wants to merge 7 commits into
SomeBottle wants to merge 7 commits into
Conversation
…ing resource file
SomeBottle
marked this pull request as ready for review
August 2, 2026 10:46
Cover compile/pdf/output with a root document in a subfolder (-r 'sub/<id>.tex'), including a negative case for a missing file, mirroring the assertion strength of the existing tests.
Absolute local paths keep their directory part in the upload command (/tmp/... becomes remote tmp/... junk folders) on Linux/macOS, breaking subsequent exact-path downloads. Windows paths (backslash) bypass this, which is why it only surfaced outside the author's environment. Switch all e2e uploads to 'cd "$TEST_DIR" && olcli upload <relative>'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Currently,
olclionly supports compiling a project's main document. In practice, however, a project may contain multiple documents that need to be compiled specifically, such asappendix.texorreproducibility_checklist.tex.The Overleaf API supports specifying the document to compile by setting the
rootResourcePathfield in the request body. Therefore, this PR adds support for selecting the compilation target inolcliusing the-r/--resourceoption.Changes
This change mainly affects the
pdf,compile, andoutputcommands.A new command-line option,
--resource <path>, along with its shorthand-r, has been added. The change is fully backward-compatible with previous versions, including the Library API.New Test Cases
upload test tex file to subfoldersub/<TEST_ID>.texusing a relative pathcompile project with --resourceolcli compile -r 'sub/<TEST_ID>.tex'succeedscompile with nonexistent --resource fails gracefully-rwith a nonexistent file exits with a non-zero statusdownload PDF with --resourceolcli pdf -r ...produces a valid PDF fileoutput --list with --resourcedownload log output with --resource.logfile for the resource-specific compilation and verifies that it is non-emptyE2E Test Results
Command:
OLCLI_E2E_PROJECT_NAME='TestProject' bash test/e2e.shResult:
Issue Discovered While Running the Tests
The
uploadcommand may not handle absolute paths correctly.olcli/test/e2e.sh
Lines 252 to 254 in 7dd9d73
$TEST_DIRis an absolute path. Therefore, ifTEST_ID=123,$TEST_FILEwill look something like this:In
cli.ts,olcli uploadnormalizes the file path using the following logic:olcli/src/cli.ts
Lines 745 to 750 in 7dd9d73
As a result,
$TEST_FILEis uploaded to a remote path such as:However, the
download single filetest attempts to download the file using only${TEST_ID}.txt. The file therefore cannot be found, causing the test to fail:olcli/test/e2e.sh
Lines 267 to 277 in 7dd9d73
As a temporary workaround, the affected test cases now enter
$TEST_DIRfirst (usingcd) before running the upload command.To address this path-resolution issue in
cli.ts, one possible solution would be to introduce a--tooption. This would allow users to explicitly specify the destination-relative path when uploading a file:What do you think? Looking forward to your reply.