mirror of
https://github.com/C4illin/ConvertX.git
synced 2026-11-09 06:50:14 +01:00
fix: version printing (#606)
Co-authored-by: Emrik Östling <emrik.ostling@gmail.com>
This commit is contained in:
@@ -8,6 +8,7 @@ if (process.env.NODE_ENV === "production") {
|
||||
readFile("/etc/os-release", "utf8", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("Not running on docker, this is not supported.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
@@ -18,6 +19,7 @@ if (process.env.NODE_ENV === "production") {
|
||||
exec("pandoc -v", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("Pandoc is not installed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
@@ -28,6 +30,7 @@ if (process.env.NODE_ENV === "production") {
|
||||
exec("ffmpeg -version", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("FFmpeg is not installed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
@@ -38,6 +41,7 @@ if (process.env.NODE_ENV === "production") {
|
||||
exec("vips -v", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("Vips is not installed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
@@ -48,6 +52,7 @@ if (process.env.NODE_ENV === "production") {
|
||||
exec("magick --version", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("ImageMagick is not installed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
@@ -58,6 +63,7 @@ if (process.env.NODE_ENV === "production") {
|
||||
exec("gm version", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("GraphicsMagick is not installed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
@@ -68,6 +74,7 @@ if (process.env.NODE_ENV === "production") {
|
||||
exec("inkscape --version", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("Inkscape is not installed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
@@ -78,6 +85,7 @@ if (process.env.NODE_ENV === "production") {
|
||||
exec("djxl --version", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("libjxl-tools is not installed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
@@ -85,19 +93,21 @@ if (process.env.NODE_ENV === "production") {
|
||||
}
|
||||
});
|
||||
|
||||
exec("dasel --version", (error, stdout) => {
|
||||
exec("dasel version", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("dasel is not installed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(stdout.split("\n")[0]);
|
||||
console.log(`dasel ${stdout.split("\n")[0]}`);
|
||||
}
|
||||
});
|
||||
|
||||
exec("xelatex -version", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("Tex Live with XeTeX is not installed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
@@ -108,36 +118,30 @@ if (process.env.NODE_ENV === "production") {
|
||||
exec("resvg -V", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("resvg is not installed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
// stdout may contain the command plus version (e.g. "resvg -V v1.0.0").
|
||||
// Extract the last token and print it as version to avoid duplication.
|
||||
const firstLine = (stdout || "").split("\n")[0] || "";
|
||||
const lastToken = (firstLine.split(" ").filter(Boolean).pop() ?? "").toString();
|
||||
console.log(`resvg ${lastToken}`);
|
||||
console.log(`resvg v${stdout.split("\n")[0]}`);
|
||||
}
|
||||
});
|
||||
|
||||
exec("assimp version", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("assimp is not installed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
// assimp prints its version on a specific line in real output; if the
|
||||
// expected line isn't present (e.g. in tests/mocks), fall back to the
|
||||
// first non-empty line. Then extract the last token as version.
|
||||
const lines = (stdout || "").split("\n").filter(Boolean);
|
||||
const candidate = (lines[5] ?? lines[0] ?? "").toString();
|
||||
const lastToken = (candidate.split(" ").filter(Boolean).pop() ?? "").toString();
|
||||
console.log(`assimp ${lastToken}`);
|
||||
const firstLines = stdout.split("\n");
|
||||
console.log(`assimp ${firstLines[5] || firstLines[0] || ""}`);
|
||||
}
|
||||
});
|
||||
|
||||
exec("ebook-convert --version", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("ebook-convert (calibre) is not installed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
@@ -148,6 +152,7 @@ if (process.env.NODE_ENV === "production") {
|
||||
exec("heif-info -v", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("libheif is not installed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
@@ -158,6 +163,7 @@ if (process.env.NODE_ENV === "production") {
|
||||
exec("potrace -v", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("potrace is not installed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
@@ -168,6 +174,7 @@ if (process.env.NODE_ENV === "production") {
|
||||
exec("soffice --version", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("libreoffice is not installed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
@@ -175,28 +182,29 @@ if (process.env.NODE_ENV === "production") {
|
||||
}
|
||||
});
|
||||
|
||||
exec("msgconvert --version", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("msgconvert (libemail-outlook-message-perl) is not installed");
|
||||
}
|
||||
// msgconvert has no version flag, so read the version of the perl module providing it
|
||||
exec(
|
||||
"perl -MEmail::Outlook::Message -e 'print $Email::Outlook::Message::VERSION'",
|
||||
(error, stdout) => {
|
||||
if (error) {
|
||||
console.error("msgconvert (libemail-outlook-message-perl) is not installed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
console.log(stdout.split("\n")[0]);
|
||||
}
|
||||
});
|
||||
if (stdout) {
|
||||
console.log(`msgconvert v${stdout.split("\n")[0]}`);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
exec("bun -v", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("Bun is not installed. wait what");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
// stdout may include the command itself (e.g. "bun -v v1.0.0"). Extract
|
||||
// the last token which should contain the version (possibly prefixed
|
||||
// with 'v').
|
||||
const firstLine = (stdout || "").split("\n")[0] || "";
|
||||
const lastToken = (firstLine.split(" ").filter(Boolean).pop() ?? "").toString();
|
||||
console.log(`Bun ${lastToken}`);
|
||||
console.log(`Bun v${stdout.split("\n")[0]}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user