mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-08-10 07:21:32 -07:00
feat(overlay): add in-app changelog modal (#187)
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
export function resolveBundledChangelogPath(deps: {
|
||||
resourcesPath: string;
|
||||
appPath: string;
|
||||
dirname: string;
|
||||
joinPath: (...parts: string[]) => string;
|
||||
fileExists: (path: string) => boolean;
|
||||
}): string | null {
|
||||
const candidates = [
|
||||
deps.joinPath(deps.resourcesPath, 'CHANGELOG.md'),
|
||||
deps.joinPath(deps.appPath, 'CHANGELOG.md'),
|
||||
deps.joinPath(deps.dirname, '..', 'CHANGELOG.md'),
|
||||
deps.joinPath(deps.dirname, '..', '..', 'CHANGELOG.md'),
|
||||
];
|
||||
|
||||
return candidates.find((candidate) => deps.fileExists(candidate)) ?? null;
|
||||
}
|
||||
|
||||
export function readBundledChangelog(deps: {
|
||||
resolvePath: () => string | null;
|
||||
readFile: (path: string) => string;
|
||||
logWarn: (message: string) => void;
|
||||
}): string | null {
|
||||
const changelogPath = deps.resolvePath();
|
||||
if (!changelogPath) return null;
|
||||
try {
|
||||
return deps.readFile(changelogPath);
|
||||
} catch (error) {
|
||||
deps.logWarn(
|
||||
`Failed to read bundled changelog at ${changelogPath}: ${
|
||||
error instanceof Error ? error.message : String(error)
|
||||
}`,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user