Remove remaining Electron imports from product code: paths & env

Summary:
This diff removes most remaining Electron imports, by storing env and path constants on the RenderHost. As nice side effect those paths are all cached now as well.

To make sure RenderHost is initialised before Flipper itself, forced loading Flipper through a require. Otherwise the setup is super sensitive to circular import statements, since a lot of module initialisation code depends on those paths / env vars.

Reviewed By: nikoant

Differential Revision: D31992230

fbshipit-source-id: 91beb430902272aaf4b051b35cdf12d2fc993347
This commit is contained in:
Michel Weststrate
2021-11-03 07:00:03 -07:00
committed by Facebook GitHub Bot
parent dba09542f9
commit 2e7015388c
20 changed files with 413 additions and 375 deletions

View File

@@ -9,14 +9,14 @@
import fs from 'fs';
import path from 'path';
import {getAppPath} from 'flipper';
import {AppMatchPattern} from '../types';
import {Device} from 'flipper-plugin';
import {Device, getFlipperLib} from 'flipper-plugin';
let patternsPath: string | undefined;
function getPatternsBasePath() {
return (patternsPath = patternsPath ?? path.join(getAppPath(), 'facebook'));
return (patternsPath =
patternsPath ?? path.join(getFlipperLib().paths.appPath, 'facebook'));
}
const extractAppNameFromSelectedApp = (selectedApp: string | null) => {