From b6372ad006c3bce94b84a0acc3f6777716f2b8d6 Mon Sep 17 00:00:00 2001 From: Anton Nikolaev Date: Fri, 12 Feb 2021 09:20:15 -0800 Subject: [PATCH] Fix appMatchPatterns error Summary: Fixed error thrown by navigation plugin in Flipper release builds (T84083443) Reviewed By: passy Differential Revision: D26402201 fbshipit-source-id: 7433457e3074c26ad17ac5158522d287232e2ede --- desktop/plugins/navigation/util/appMatchPatterns.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/desktop/plugins/navigation/util/appMatchPatterns.tsx b/desktop/plugins/navigation/util/appMatchPatterns.tsx index 4c57e567e..16fa1b1e0 100644 --- a/desktop/plugins/navigation/util/appMatchPatterns.tsx +++ b/desktop/plugins/navigation/util/appMatchPatterns.tsx @@ -11,6 +11,14 @@ import fs from 'fs'; import path from 'path'; import {BaseDevice, AndroidDevice, IOSDevice} from 'flipper'; import {AppMatchPattern} from '../types'; +import {remote} from 'electron'; + +let patternsPath: string | undefined; + +function getPatternsBasePath() { + return (patternsPath = + patternsPath ?? path.join(remote.app.getAppPath(), 'facebook')); +} const extractAppNameFromSelectedApp = (selectedApp: string | null) => { if (selectedApp == null) { @@ -35,7 +43,7 @@ export const getAppMatchPatterns = ( } else { return; } - const patternsPath = path.join('facebook', filename); + patternsPath = path.join(getPatternsBasePath(), filename); fs.readFile(patternsPath, (err, data) => { if (err) { reject(err);