From 864e296f35cf0726d94b7f411e8bdc4db854e954 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Tue, 21 Nov 2023 10:30:06 -0800 Subject: [PATCH] Recover from corrupted config.json Summary: This has caused a few tasks to be raised. We do replace broken configs with a fresh template elsewhere, but we shouldn't throw in this place since we have a fallback. Reviewed By: antonk52 Differential Revision: D51393314 fbshipit-source-id: 8c04946c5b0e74f5f0d42c9492aa381aa608fd35 --- desktop/plugin-lib/src/pluginPaths.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/desktop/plugin-lib/src/pluginPaths.tsx b/desktop/plugin-lib/src/pluginPaths.tsx index 382f14087..16d6dda80 100644 --- a/desktop/plugin-lib/src/pluginPaths.tsx +++ b/desktop/plugin-lib/src/pluginPaths.tsx @@ -30,7 +30,12 @@ export async function getPluginSourceFolders(): Promise { const pluginFolders: string[] = []; const flipperConfigPath = path.join(homedir(), '.flipper', 'config.json'); if (await fs.pathExists(flipperConfigPath)) { - const config = await fs.readJson(flipperConfigPath); + let config = {pluginPaths: []}; + try { + config = await fs.readJson(flipperConfigPath); + } catch (e) { + console.error('Failed to read local flipper config: ', e); + } if (config.pluginPaths) { pluginFolders.push(...config.pluginPaths); }