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
This commit is contained in:
Anton Nikolaev
2021-02-12 09:20:15 -08:00
committed by Facebook GitHub Bot
parent b4ec0d62a5
commit b6372ad006

View File

@@ -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);