diff --git a/desktop/app/src/utils/info.tsx b/desktop/app/src/utils/info.tsx index fec79c43c..a236df464 100644 --- a/desktop/app/src/utils/info.tsx +++ b/desktop/app/src/utils/info.tsx @@ -8,7 +8,7 @@ */ import os from 'os'; -import {remote} from 'electron'; +import {isTest} from './isProduction'; export type Info = { arch: string; @@ -36,15 +36,12 @@ 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; +let APP_VERSION: string | undefined; +export function getAppVersion(): string { + return (APP_VERSION = + APP_VERSION ?? + process.env.FLIPPER_FORCE_VERSION ?? + (isTest() ? '0.0.0' : require('../../package.json').version ?? '0.0.0')); } export function stringifyInfo(info: Info): string { diff --git a/desktop/scripts/start-dev-server.ts b/desktop/scripts/start-dev-server.ts index 3b8fa4571..711e7482b 100644 --- a/desktop/scripts/start-dev-server.ts +++ b/desktop/scripts/start-dev-server.ts @@ -85,6 +85,11 @@ const argv = yargs '[FB-internal only] Will force using public sources only, to be able to iterate quickly on the public version. If sources are checked out from GitHub this is already the default. Setting env var "FLIPPER_FORCE_PUBLIC_BUILD" is equivalent.', type: 'boolean', }, + 'force-version': { + describe: + 'Will force using the given value as Flipper version, to be able to test logic which is version-dependent. Setting env var "FLIPPER_FORCE_VERSION" is equivalent.', + type: 'string', + }, }) .version('DEV') .help() @@ -152,6 +157,10 @@ if (argv.channel !== undefined) { process.env.FLIPPER_RELEASE_CHANNEL = argv.channel; } +if (argv['force-version']) { + process.env.FLIPPER_FORCE_VERSION = argv['force-version']; +} + function looksLikeDevServer(): boolean { const hn = hostname(); if (/^devvm.*\.facebook\.com$/.test(hn)) {