Files
flipper/src/utils/processConfig.js
Pascal Hartig c0b5f10693 Add --launcher-msg option to pass to desktop app
Summary:
Allows the launcher to provide messages to the user. Currently, in the form
of the red notification bar at the bottom. This is just meant as a temporary measure
during the alpha to have some clearly noticeable way of getting the user's attention.

I consider removing this a blocker for the release as this mechanism is not well
suited for this in many ways.

The current use case for this is providing a warning if a cached version is used
instead of the requested one, e.g. "Could not fetch requested Flipper version 'deadbeef', using cached version instead."

Reviewed By: jknoxville, priteshrnandgaonkar

Differential Revision: D14073687

fbshipit-source-id: 85630347027063103315eeb1286731fe2478e261
2019-02-14 06:02:44 -08:00

47 lines
1.3 KiB
JavaScript

/**
* Copyright 2018-present Facebook.
* 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';
export type ProcessConfig = {|
disabledPlugins: Set<string>,
pluginPaths: Array<string>,
lastWindowPosition: ?{x: number, y: number, width: number, height: number},
screenCapturePath: ?string,
launcherMsg: ?string,
updaterEnabled: boolean,
// Controls whether to delegate to the launcher if present.
launcherEnabled: boolean,
|};
let configObj = null;
export default function config(): ProcessConfig {
if (configObj === null) {
const json = JSON.parse(
// $FlowFixMe: process.env not in type defs
remote?.process.env.CONFIG || process.env.CONFIG || '{}',
);
configObj = {
disabledPlugins: new Set(json.disabledPlugins || []),
pluginPaths: json.pluginPaths || [],
lastWindowPosition: json.lastWindowPosition,
launcherMsg: json.launcherMsg,
updaterEnabled:
typeof json.updaterEnabled === 'boolean' ? json.updaterEnabled : true,
screenCapturePath: json.screenCapturePath,
launcherEnabled:
typeof json.launcherEnabled === 'boolean' ? json.launcherEnabled : true,
};
}
return configObj;
}
export function resetConfigForTesting() {
configObj = null;
}