fix(utf8): закрыть lossy-границы конфигурации и API
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
import { parseUpstreamHashes } from "../src/build/hysteriaRelease";
|
||||
import { readText } from "../src/lib/fs";
|
||||
|
||||
function fail(message: string): never {
|
||||
console.error(`[hy2xs-build] ERROR: ${message}`);
|
||||
@@ -47,7 +48,7 @@ function parseArgs(argv: string[]): { file: string; asset: string } {
|
||||
const { file, asset } = parseArgs(Bun.argv.slice(2));
|
||||
|
||||
try {
|
||||
const text = await Bun.file(file).text();
|
||||
const text = await readText(file);
|
||||
process.stdout.write(`${parseUpstreamHashes(text, asset)}\n`);
|
||||
} catch (error) {
|
||||
fail(error instanceof Error ? error.message : String(error));
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
import { parseRuntimeEnv } from "../src/config/env";
|
||||
import { HYSTERIA_OBFS_TYPES } from "../src/config/profile";
|
||||
import { readText } from "../src/lib/fs";
|
||||
import { hysteriaConfigTemplatePath, renderHysteriaConfig } from "../src/steps/config";
|
||||
import type { RuntimeContext } from "../src/types/context";
|
||||
|
||||
@@ -138,7 +139,7 @@ async function main(): Promise<void> {
|
||||
overrides.HY2XS_HYSTERIA_TRAFFIC_STATS_PORT = options.trafficStatsPort;
|
||||
}
|
||||
|
||||
const sourceEnv = await Bun.file(options.configPath).text();
|
||||
const sourceEnv = await readText(options.configPath);
|
||||
const config = parseRuntimeEnv(overrideEnv(sourceEnv, overrides));
|
||||
|
||||
const context = {
|
||||
@@ -160,7 +161,7 @@ async function main(): Promise<void> {
|
||||
hysteriaResolution: "compat-gate"
|
||||
} satisfies RuntimeContext;
|
||||
|
||||
const template = await Bun.file(options.templatePath).text();
|
||||
const template = await readText(options.templatePath);
|
||||
await Bun.write(options.outPath, renderHysteriaConfig(context, template));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user