try catch for potentially bad json

This commit is contained in:
booploops 2022-05-05 04:14:12 -07:00
parent 1d8dfb3ace
commit e3bbfd1904

View file

@ -4,7 +4,18 @@ import * as windowStateKeeper from "electron-window-state";
import * as express from "express";
import * as getPort from "get-port";
import {search} from "youtube-search-without-api-key";
import { existsSync, rmSync, mkdirSync, readdirSync, readFileSync, writeFileSync, statSync, unlinkSync, rmdirSync, lstatSync } from "fs";
import {
existsSync,
rmSync,
mkdirSync,
readdirSync,
readFileSync,
writeFileSync,
statSync,
unlinkSync,
rmdirSync,
lstatSync
} from "fs";
import {Stream} from "stream";
import {networkInterfaces} from "os";
import * as mm from 'music-metadata';
@ -887,6 +898,7 @@ export class BrowserWindow {
themePath = themePath.slice(0, -10);
}
if (existsSync(join(themePath, "theme.json"))) {
try {
let themeJson = JSON.parse(readFileSync(join(themePath, "theme.json"), "utf8"));
themeObjects.push({
name: themeJson.name || themeName,
@ -897,6 +909,9 @@ export class BrowserWindow {
commit: themeJson.commit || "",
pack: themeJson.pack || false,
});
} catch (e) {
console.error(e);
}
} else {
themeObjects.push({
name: themeName,