fix: return an empty object if yaml file is empty

This commit is contained in:
Bazyli Brzoska
2025-10-03 19:41:42 -07:00
parent 9f5c2dbe92
commit 54853098a7

View File

@@ -76,7 +76,7 @@ export const loadMiddlewares = <T>() => {
throw new Error(`File not found: ${configPath}`);
}
const yamlStr = readFileSync(configPath, "utf8");
const config = parse(yamlStr) as T;
const config = (parse(yamlStr) ?? {}) as T;
return config;
};
@@ -94,7 +94,7 @@ export const loadRemoteMiddlewares = async (serverId: string) => {
console.error(`Error: ${stderr}`);
throw new Error(`File not found: ${configPath}`);
}
const config = parse(stdout) as FileConfig;
const config = (parse(stdout) ?? {}) as FileConfig;
return config;
} catch (_) {
throw new Error(`File not found: ${configPath}`);