fix(index): skip version checks for false boolean options (#751)

* fix(index): skip version checks for `false` boolean options

* test(index): version skip check
This commit is contained in:
Frazer Smith
2026-02-24 18:36:04 +00:00
committed by GitHub
parent 1378e0dc3e
commit f0e42f34ad
2 changed files with 30 additions and 9 deletions
+11 -9
View File
@@ -609,16 +609,18 @@ function parseOptions(acceptedOptions, options, version) {
const optionType = typeof option;
if (acceptedOption.type === optionType) {
// Skip boolean options if false
if (acceptedOption.type !== "boolean" || option) {
// Arg will be empty for some non-standard options
if (acceptedOption.arg !== "") {
args.push(acceptedOption.arg);
}
// Boolean options set to false won't be passed to the binary; skip arg and version checks
if (acceptedOption.type === "boolean" && !option) {
continue;
}
if (optionType !== "boolean") {
args.push(option);
}
// Arg will be empty for some non-standard options
if (acceptedOption.arg !== "") {
args.push(acceptedOption.arg);
}
if (optionType !== "boolean") {
args.push(option);
}
} else {
invalidArgs.push(
+19
View File
@@ -1237,6 +1237,25 @@ describe("Node-Poppler module", () => {
}
});
it("Does not reject with an Error object if option provided is only available in a later version of the pdftoppm binary than what was provided, but is set to false", async () => {
const options = {
printProgress: false,
};
if (lt(version, "21.03.0", { loose: true })) {
const res = await poppler.pdfToPpm(
file,
`${testDirectory}pdf_1.3_NHS_Constitution`,
options
);
expect(res).toBe("No Error");
await expect(
access(`${testDirectory}pdf_1.3_NHS_Constitution-01.ppm`)
).resolves.toBeUndefined();
}
});
it("Rejects with an Error object if invalid option is passed to function", async () => {
const options = {
middlePageToConvert: "test",