mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-10 04:19:25 -07:00
feat(core): add Electron runtime, services, and app composition
This commit is contained in:
17
src/config/parse.ts
Normal file
17
src/config/parse.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { parse as parseJsonc, type ParseError } from 'jsonc-parser';
|
||||
|
||||
export function parseConfigContent(configPath: string, data: string): unknown {
|
||||
if (!configPath.endsWith('.jsonc')) {
|
||||
return JSON.parse(data);
|
||||
}
|
||||
|
||||
const errors: ParseError[] = [];
|
||||
const result = parseJsonc(data, errors, {
|
||||
allowTrailingComma: true,
|
||||
disallowComments: false,
|
||||
});
|
||||
if (errors.length > 0) {
|
||||
throw new Error(`Invalid JSONC (${errors[0]?.error ?? 'unknown'})`);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user