feat:检测是否安装Java fix:修复彩色字体无法显示

This commit is contained in:
Tianpao
2025-07-24 11:22:01 +08:00
parent 777d8e43aa
commit 9f9cfc3e17
5 changed files with 29 additions and 25 deletions

View File

@@ -1,4 +1,4 @@
import chalk from "chalk";
import pc from "picocolors"
export const LOGGER = {
info(text: string) {
info(text);
@@ -12,17 +12,17 @@ export const LOGGER = {
};
function info(text: string) {
console.log(
`[${chalk.blue(
`[${pc.blue(
new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString()
)}](${process.pid})[${chalk.green("INFO")}]:${chalk.cyan(text)}`
)}](${process.pid})[${pc.green("INFO")}]:${pc.cyan(text)}`
);
}
function warn(text: string) {
console.log(
`[${chalk.blue(
`[${pc.blue(
new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString()
)}](${process.pid})[${chalk.yellowBright("WARN")}]:${chalk.yellowBright(
)}](${process.pid})[${pc.yellowBright("WARN")}]:${pc.yellowBright(
text
)}`
);
@@ -30,15 +30,15 @@ function warn(text: string) {
function error(error: object | string | unknown) {
if (typeof error === "object") {
console.log(
`[${chalk.blue(
`[${pc.blue(
new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString()
)}](${process.pid})[${chalk.red("ERROR")}:${JSON.stringify(error)}`
)}](${process.pid})[${pc.red("ERROR")}:${JSON.stringify(error)}`
);
} else {
console.log(
`[${chalk.blue(
`[${pc.blue(
new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString()
)}](${process.pid})[${chalk.red("ERROR")}:${error}`
)}](${process.pid})[${pc.red("ERROR")}:${error}`
);
}
}

View File

@@ -8,6 +8,7 @@ import env from "dotenv";
import { MultiBar } from "cli-progress";
import { URL, fileURLToPath } from "node:url";
import { LOGGER } from "./logger.js";
import { exec } from "node:child_process";
export async function readzipentry(
zipfile: yauzl.ZipFile,
@@ -179,3 +180,15 @@ export const isDevelopment = (() => {
env.config();
return process.env.DEVELOPMENT;
})();
export const isInstallJava:Promise<boolean> = (() => {
return new Promise((resolve) => {
exec("java -version", (err) => {
if (err) {
resolve(false);
} else {
resolve(true);
}
});
});
})();