Skip to content

Commit

Permalink
fix: hidden shell output and fix jsdoc typo
Browse files Browse the repository at this point in the history
  • Loading branch information
northword committed Dec 11, 2024
1 parent f6e6011 commit ebb6f29
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 36 deletions.
58 changes: 23 additions & 35 deletions src/core/tester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import process, { cwd, env } from "node:process";
import { build } from "esbuild";
import fsExtra from "fs-extra/esm";
import { globbySync } from "globby";
import { isCI, isLinux, isMacOS } from "std-env";
import { isCI, isLinux } from "std-env";
import { Xvfb } from "xvfb-ts";
import { saveResource } from "../utils/file.js";
import { toArray } from "../utils/string.js";
Expand Down Expand Up @@ -530,7 +530,7 @@ mocha.run();
res.end(JSON.stringify({ message: "Results received successfully" }));
}
catch (error: any) {
console.error("Error parsing JSON:", error);
this.logger.error("Error parsing JSON:", error);
res.writeHead(400, { "Content-Type": "application/json" });
res.end(JSON.stringify({ error: "Invalid JSON" }));
}
Expand Down Expand Up @@ -600,55 +600,43 @@ mocha.run();
}

async installXvfb() {
if (!isLinux) {
this.logger.error("Unsupported platform. Please install Xvfb manually.");
process.exit(1);
}
try {
execSync("which xvfb", { stdio: "ignore" });
}
catch {
if (isLinux) {
try {
const osId = execSync("cat /etc/os-release | grep '^ID='").toString();
if (osId.includes("ubuntu") || osId.includes("debian")) {
this.logger.debug("Detected Ubuntu/Debian. Installing Xvfb...");
execSync("sudo apt-get update && sudo apt-get install -y xvfb", { stdio: "inherit" });
}
else if (osId.includes("centos") || osId.includes("rhel")) {
this.logger.debug("Detected CentOS/RHEL. Installing Xvfb...");
execSync("sudo yum install -y xorg-x11-server-Xvfb", { stdio: "inherit" });
}
else {
throw new Error("Unsupported Linux distribution.");
}
this.logger.debug("Xvfb installation completed.");
}
catch (error) {
console.error("Failed to install Xvfb:", error);
process.exit(1);
try {
const osId = execSync("cat /etc/os-release | grep '^ID='").toString();
if (osId.includes("ubuntu") || osId.includes("debian")) {
this.logger.debug("Detected Ubuntu/Debian. Installing Xvfb...");
execSync("sudo apt-get update && sudo apt-get install -y xvfb", { stdio: "pipe" });
}
}
else if (isMacOS) {
this.logger.debug("Detected macOS. Installing XQuartz...");
try {
execSync("brew install xquartz", { stdio: "inherit" });
this.logger.debug("XQuartz installation completed.");
else if (osId.includes("centos") || osId.includes("rhel")) {
this.logger.debug("Detected CentOS/RHEL. Installing Xvfb...");
execSync("sudo yum install -y xorg-x11-server-Xvfb", { stdio: "pipe" });
}
catch (error) {
console.error("Failed to install XQuartz:", error);
process.exit(1);
else {
throw new Error("Unsupported Linux distribution.");
}
this.logger.debug("Xvfb installation completed.");
}
else {
console.error("Unsupported platform. Please install Xvfb manually.");
catch (error) {
this.logger.error("Failed to install Xvfb:", error);
process.exit(1);
}
}
}

async installZoteroLinux() {
try {
execSync("wget -O zotero.tar.bz2 'https://www.zotero.org/download/client/dl?platform=linux-x86_64&channel=beta'");
execSync("tar -xvf zotero.tar.bz2");
execSync("wget -O zotero.tar.bz2 'https://www.zotero.org/download/client/dl?platform=linux-x86_64&channel=beta'", { stdio: "pipe" });
execSync("tar -xvf zotero.tar.bz2", { stdio: "pipe" });
}
catch {
catch (e) {
this.logger.error(e);
throw new Error("Zotero extracted failed");
}
}
Expand Down
15 changes: 14 additions & 1 deletion src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ export interface TestConfig {
*
* 测试的超时时间。
*
* @default 5000
* @default 10000
*/
timeout: number;
};
Expand Down Expand Up @@ -612,6 +612,19 @@ export interface TestConfig {
*/
exitOnFinish: boolean;

/**
* Run Zotero in deadless mode.
*
* - Supported for Linux only.
* - Default to true when in CI environments.
*
* 使用无头模式运行 Zotero。
*
* - 仅支持 Linux
* - 在 CI 模式下,默认为 true
*
* @default false
*/
headless: boolean;

/**
Expand Down

0 comments on commit ebb6f29

Please sign in to comment.