Skip to content

Commit

Permalink
No not delegate launch to Flipper Launcher
Browse files Browse the repository at this point in the history
Summary: ^

Reviewed By: aigoncharov

Differential Revision: D50557385

fbshipit-source-id: d9571dda36520eae19f2d5fda4f52807f439a4e1
  • Loading branch information
lblasa authored and facebook-github-bot committed Oct 24, 2023
1 parent bf49924 commit da7917c
Showing 1 changed file with 42 additions and 51 deletions.
93 changes: 42 additions & 51 deletions desktop/static/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import fixPath from 'fix-path';
import {exec} from 'child_process';
import setup, {Config, configPath} from './setup';
import isFB from './fb-stubs/isFB';
import delegateToLauncher from './launcher';
import yargs from 'yargs';
import {promisify} from 'util';
import process from 'process';
Expand Down Expand Up @@ -174,58 +173,50 @@ app.on('ready', async () => {
const config = await setup(argv);
processConfig(config);

// If we delegate to the launcher, shut down this instance of the app.
delegateToLauncher(argv)
.then(async (hasLauncherInvoked: boolean) => {
if (hasLauncherInvoked) {
app.quit();
return;
appReady = true;

app.commandLine.appendSwitch('scroll-bounce');
configureSession();
createWindow(config);

// if in development install the react devtools extension
if (process.env.NODE_ENV === 'development') {
const {
default: installExtension,
REACT_DEVELOPER_TOOLS,
} = require('electron-devtools-installer');
// if set, try to download a newever version of the dev tools
const forceDownload = process.env.FLIPPER_UPDATE_DEV_TOOLS === 'true';
if (forceDownload) {
console.log('Force updating DevTools');
}
// React
// Fix for extension loading (see D27685981)
// Work around per https://github.com/electron/electron/issues/23662#issuecomment-787420799
const reactDevToolsPath = `${os.homedir()}/Library/Application Support/Electron/extensions/${
REACT_DEVELOPER_TOOLS.id
}`;
if (await promisify(fs.exists)(reactDevToolsPath)) {
console.log('Loading React devtools from disk ' + reactDevToolsPath);
try {
await session.defaultSession.loadExtension(
reactDevToolsPath,
// @ts-ignore only supported (and needed) in Electron 12
{allowFileAccess: true},
);
} catch (e) {
console.error('Failed to load React devtools from disk: ', e);
}
appReady = true;
app.commandLine.appendSwitch('scroll-bounce');
configureSession();
createWindow(config);

// if in development install the react devtools extension
if (process.env.NODE_ENV === 'development') {
const {
default: installExtension,
REACT_DEVELOPER_TOOLS,
} = require('electron-devtools-installer');
// if set, try to download a newever version of the dev tools
const forceDownload = process.env.FLIPPER_UPDATE_DEV_TOOLS === 'true';
if (forceDownload) {
console.log('Force updating DevTools');
}
// React
// Fix for extension loading (see D27685981)
// Work around per https://github.com/electron/electron/issues/23662#issuecomment-787420799
const reactDevToolsPath = `${os.homedir()}/Library/Application Support/Electron/extensions/${
REACT_DEVELOPER_TOOLS.id
}`;
if (await promisify(fs.exists)(reactDevToolsPath)) {
console.log('Loading React devtools from disk ' + reactDevToolsPath);
try {
await session.defaultSession.loadExtension(
reactDevToolsPath,
// @ts-ignore only supported (and needed) in Electron 12
{allowFileAccess: true},
);
} catch (e) {
console.error('Failed to load React devtools from disk: ', e);
}
} else {
try {
await installExtension(REACT_DEVELOPER_TOOLS.id, {
loadExtensionOptions: {allowFileAccess: true, forceDownload},
});
} catch (e) {
console.error('Failed to install React devtools extension', e);
}
}
} else {
try {
await installExtension(REACT_DEVELOPER_TOOLS.id, {
loadExtensionOptions: {allowFileAccess: true, forceDownload},
});
} catch (e) {
console.error('Failed to install React devtools extension', e);
}
})
.catch((e: any) => console.error('Error while delegating app launch', e));
}
}
});

app.on('web-contents-created', (_event, contents) => {
Expand Down

0 comments on commit da7917c

Please sign in to comment.