mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-30 21:01:54 +08:00
fix: narrow ParsedConfigValue to LocalEmulatorConfigValue with type guard
Co-Authored-By: mantra <mantra@stack-auth.com>
This commit is contained in:
parent
f71cde84b8
commit
97b1a2f960
@ -76,7 +76,14 @@ async function readConfigContent(filePath: string): Promise<string> {
|
||||
async function readConfigValueFromFile(filePath: string): Promise<LocalEmulatorConfigValue> {
|
||||
const content = await readConfigContent(filePath);
|
||||
try {
|
||||
return evalConfigFileContent(content, filePath);
|
||||
const result = evalConfigFileContent(content, filePath);
|
||||
if (typeof result === "string") {
|
||||
if (result !== LOCAL_EMULATOR_SHOW_ONBOARDING_VALUE) {
|
||||
throw new Error(`Unexpected string config value: ${JSON.stringify(result)}`);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
} catch (e) {
|
||||
const message = e instanceof Error ? e.message : String(e);
|
||||
throw new StatusError(StatusError.BadRequest, `Error evaluating config in ${filePath}: ${message}`);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user