Real restart in dev mode

Summary: To test plugin installation I need to restart Flipper often, however restart in dev mode is not "true" restart - instead it just reloads the window and doesn't load freshly installed plugins. To make my life easier I have implemented more realistic way for restart in dev mode.

Reviewed By: jknoxville

Differential Revision: D19770263

fbshipit-source-id: 8755663746dc265e0826ed79b9782e073132537f
This commit is contained in:
Anton Nikolaev
2020-02-06 09:41:44 -08:00
committed by Facebook Github Bot
parent b9e7f5d6d1
commit 1b6ce47be2
2 changed files with 36 additions and 11 deletions

View File

@@ -15,10 +15,10 @@ export default function restart() {
remote.app.relaunch();
remote.app.exit();
} else {
// Relaunching the process doesn't work in dev mode
// because it just launches an empty electron shell.
// Instead, approximate it by doing a refresh.
// Should be roughly equivalent but there may be some differences.
remote.getCurrentWindow().reload();
// Relaunching the process with the standard way doesn't work in dev mode.
// So instead we're sending a signal to dev server to kill the current instance of electron and launch new.
fetch(`${remote.process.env.DEV_SERVER_URL}/_restartElectron`, {
method: 'POST',
});
}
}