mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-21 00:11:27 -07:00
fix(core): recopy Yomitan extension when patched scripts drift
This commit is contained in:
@@ -2,6 +2,7 @@ import { BrowserWindow, Extension, session } from 'electron';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { createLogger } from '../../logger';
|
||||
import { shouldCopyYomitanExtension } from './yomitan-extension-copy';
|
||||
|
||||
const logger = createLogger('main:yomitan-extension-loader');
|
||||
|
||||
@@ -22,27 +23,7 @@ function ensureExtensionCopy(sourceDir: string, userDataPath: string): string {
|
||||
const extensionsRoot = path.join(userDataPath, 'extensions');
|
||||
const targetDir = path.join(extensionsRoot, 'yomitan');
|
||||
|
||||
const sourceManifest = path.join(sourceDir, 'manifest.json');
|
||||
const targetManifest = path.join(targetDir, 'manifest.json');
|
||||
|
||||
let shouldCopy = !fs.existsSync(targetDir);
|
||||
if (!shouldCopy && fs.existsSync(sourceManifest) && fs.existsSync(targetManifest)) {
|
||||
try {
|
||||
const sourceVersion = (
|
||||
JSON.parse(fs.readFileSync(sourceManifest, 'utf-8')) as {
|
||||
version: string;
|
||||
}
|
||||
).version;
|
||||
const targetVersion = (
|
||||
JSON.parse(fs.readFileSync(targetManifest, 'utf-8')) as {
|
||||
version: string;
|
||||
}
|
||||
).version;
|
||||
shouldCopy = sourceVersion !== targetVersion;
|
||||
} catch {
|
||||
shouldCopy = true;
|
||||
}
|
||||
}
|
||||
const shouldCopy = shouldCopyYomitanExtension(sourceDir, targetDir);
|
||||
|
||||
if (shouldCopy) {
|
||||
fs.mkdirSync(extensionsRoot, { recursive: true });
|
||||
|
||||
Reference in New Issue
Block a user