mirror of
https://github.com/C4illin/ConvertX.git
synced 2026-10-27 23:30:55 +01:00
aabd0ccb3d
* feat: add DjVu conversion support * fix: support DjVu aliases and prioritize converter * fix: restore DjVu converter priority * [autofix.ci] apply automated fixes --------- Co-authored-by: Alex N <alex@alex-n.net> Co-authored-by: Emrik Östling <emrik.ostling@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
40 lines
871 B
TypeScript
40 lines
871 B
TypeScript
import { execFile as execFileOriginal } from "node:child_process";
|
|
import type { ExecFileFn } from "./types";
|
|
|
|
export const properties = {
|
|
from: {
|
|
document: ["djvu", "djv"],
|
|
},
|
|
to: {
|
|
document: ["pdf", "tiff"],
|
|
},
|
|
};
|
|
|
|
export function convert(
|
|
filePath: string,
|
|
_fileType: string,
|
|
convertTo: string,
|
|
targetPath: string,
|
|
_options?: unknown,
|
|
execFile: ExecFileFn = execFileOriginal,
|
|
): Promise<string> {
|
|
return new Promise((resolve, reject) => {
|
|
execFile("ddjvu", [`-format=${convertTo}`, filePath, targetPath], (error, stdout, stderr) => {
|
|
if (error) {
|
|
reject(`error: ${error}${stderr ? `\nstderr: ${stderr}` : ""}`);
|
|
return;
|
|
}
|
|
|
|
if (stdout) {
|
|
console.log(`stdout: ${stdout}`);
|
|
}
|
|
|
|
if (stderr) {
|
|
console.error(`stderr: ${stderr}`);
|
|
}
|
|
|
|
resolve("Done");
|
|
});
|
|
});
|
|
}
|