Extract getAppVersion() util
Summary: Just some simple memoisation so we limit this particular `remote` call to one per session. Reviewed By: mweststrate Differential Revision: D26223274 fbshipit-source-id: 7a12764758823c52f68fb7075f46caf58affb22f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
40abef860f
commit
642d89213d
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
import os from 'os';
|
||||
import {remote} from 'electron';
|
||||
|
||||
export type Info = {
|
||||
arch: string;
|
||||
@@ -35,6 +36,17 @@ export function getInfo(): Info {
|
||||
};
|
||||
}
|
||||
|
||||
let APP_VERSION: string | undefined = undefined;
|
||||
// Prefer using this function over manually calling `remote.app.getVersion()`
|
||||
// as calls to the remote object go over IPC and can be slow.
|
||||
export function getAppVersion(): string | undefined {
|
||||
if (APP_VERSION === undefined && remote) {
|
||||
APP_VERSION = remote.app.getVersion();
|
||||
}
|
||||
|
||||
return APP_VERSION;
|
||||
}
|
||||
|
||||
export function stringifyInfo(info: Info): string {
|
||||
const lines = [
|
||||
`Platform: ${info.platform} ${info.arch}`,
|
||||
|
||||
Reference in New Issue
Block a user