mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-19 19:32:18 +02:00
refactor(make-pdf): print through Aside first, the bundled browser otherwise
asideClient.ts replaces the direct $B client with one render() call per PDF (the exact option mapping the browse pdf command had: paper, margins, header/footer/page numbers, tagged, outline, printBackground, preferCSSPageSize, Paged.js wait); the diagram pre-pass, oversized-image downscale and DOCX rasters each run as one render script with per-fence try/catch; exit 4 now means no browser is available and names both remedies; $P setup reports which engine it found. The e2e gates run on whichever engine is present, so the Linux lane exercises the fallback. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -147,6 +147,30 @@ describe("findExecutable (pdftotext.ts)", () => {
|
||||
test("returns null when no extension matches", () => {
|
||||
expect(findExecutable("/nonexistent/path/to/nothing")).toBeNull();
|
||||
});
|
||||
|
||||
// access(X_OK) is TRUE for directories (they carry the traverse bit), so a bare
|
||||
// X_OK probe once resolved a docs folder as "the binary". Only regular files count.
|
||||
test("rejects a DIRECTORY even though it passes access(X_OK)", () => {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "mkpdf-dir-"));
|
||||
try {
|
||||
fs.accessSync(dir, fs.constants.X_OK); // precondition: the bare probe passes
|
||||
expect(findExecutable(dir)).toBeNull();
|
||||
} finally {
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("rejects a directory that shadows the binary name", () => {
|
||||
const base = fs.mkdtempSync(path.join(os.tmpdir(), "mkpdf-shadow-"));
|
||||
const shadow = path.join(base, "pdftotext");
|
||||
fs.mkdirSync(shadow);
|
||||
fs.writeFileSync(path.join(shadow, "README.md"), "# not a binary\n");
|
||||
try {
|
||||
expect(findExecutable(shadow)).toBeNull();
|
||||
} finally {
|
||||
fs.rmSync(base, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolvePdftotext (override resolution, v1.24-aligned)", () => {
|
||||
|
||||
Reference in New Issue
Block a user