fix(server): code block themes not listed again

This commit is contained in:
Elian Doran 2025-05-08 18:51:37 +03:00
parent ea03381801
commit 73f69f91f2
No known key found for this signature in database
2 changed files with 7 additions and 6 deletions

View File

@ -1,11 +1,12 @@
import { describe, expect, it } from "vitest"; import { describe, expect, it } from "vitest";
import { getStylesDirectory, readThemesFromFileSystem } from "./code_block_theme.js"; import { readThemesFromFileSystem } from "./code_block_theme.js";
import themeNames from "./code_block_theme_names.json" with { type: "json" }; import themeNames from "./code_block_theme_names.json" with { type: "json" };
import path = require("path");
describe("Code block theme", () => { describe("Code block theme", () => {
it("all themes are mapped", () => { it("all themes are mapped", () => {
const themes = readThemesFromFileSystem(getStylesDirectory()); const themes = readThemesFromFileSystem(path.join(__dirname, "../../node_modules/@highlightjs/cdn-assets/styles"));
const mappedThemeNames = new Set(Object.values(themeNames)); const mappedThemeNames = new Set(Object.values(themeNames));
const unmappedThemeNames = new Set<string>(); const unmappedThemeNames = new Set<string>();

View File

@ -30,7 +30,7 @@ interface ColorTheme {
* @returns the supported themes, grouped. * @returns the supported themes, grouped.
*/ */
export function listSyntaxHighlightingThemes() { export function listSyntaxHighlightingThemes() {
const path = join(getResourceDir(), getStylesDirectory()); const path = getStylesDirectory();
const systemThemes = readThemesFromFileSystem(path); const systemThemes = readThemesFromFileSystem(path);
return { return {
@ -46,11 +46,11 @@ export function listSyntaxHighlightingThemes() {
export function getStylesDirectory() { export function getStylesDirectory() {
if (isElectron && !isDev) { if (isElectron && !isDev) {
return "styles"; return join(getResourceDir(), "styles");
} else if (!isDev) { } else if (!isDev) {
return "node_modules/@highlightjs/cdn-assets/styles"; return join(getResourceDir(), "node_modules/@highlightjs/cdn-assets/styles");
} else { } else {
return join(__dirname, "../../node_modules/@highlightjs/cdn-assets/styles"); return join(__dirname, "../node_modules/@highlightjs/cdn-assets/styles");
} }
} }