Convert utils/processConfig to TS

Reviewed By: danielbuechele

Differential Revision: D16710602

fbshipit-source-id: 3dbccdb0aedd3d5415487d690fb943aafdafa0f0
This commit is contained in:
John Knox
2019-08-12 03:02:16 -07:00
committed by Facebook Github Bot
parent fda506086f
commit 882d7e1a39
6 changed files with 20 additions and 15 deletions

View File

@@ -5,7 +5,7 @@
* @format
*/
import {default as config, resetConfigForTesting} from '../processConfig.js';
import {default as config, resetConfigForTesting} from '../processConfig.tsx';
afterEach(() => {
resetConfigForTesting();

View File

@@ -5,7 +5,7 @@
* @format
*/
import type {ProcessConfig} from './processConfig.js';
import type {ProcessConfig} from './processConfig.tsx';
import type {Store} from '../reducers/index.tsx';
export function initLauncherHooks(config: ProcessConfig, store: Store) {

View File

@@ -7,23 +7,28 @@
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,
export type ProcessConfig = {
disabledPlugins: Set<string>;
pluginPaths: Array<string>;
lastWindowPosition: {
x: number;
y: number;
width: number;
height: number;
} | null;
screenCapturePath: string | null;
launcherMsg: string | null;
updaterEnabled: boolean;
// Controls whether to delegate to the launcher if present.
launcherEnabled: boolean,
|};
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 || '{}',
(remote && remote.process.env.CONFIG) || process.env.CONFIG || '{}',
);
configObj = {
disabledPlugins: new Set(json.disabledPlugins || []),