Summary: Centralizes the restart logic. And adds ability for it to work in dev mode as well. Reviewed By: passy Differential Revision: D18008197 fbshipit-source-id: b76ac7935d5859dfdbb8cf593462f8ac02348181
25 lines
683 B
TypeScript
25 lines
683 B
TypeScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import {remote} from 'electron';
|
|
import isProduction from './isProduction';
|
|
|
|
export default function restart() {
|
|
if (isProduction()) {
|
|
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();
|
|
}
|
|
}
|