Refactor headless start function

Summary: Refactors the headless to have a list of closures instead of the `if` conditions. This will make addition of new arguments easy as it will be just adding a new closure to the list. One can change the order of the execution of the closures by inserting it at whatever index the user wants.

Reviewed By: passy

Differential Revision: D15965142

fbshipit-source-id: e9f348fe9d9011adcd47d140713d6187eab3b3d3
This commit is contained in:
Pritesh Nandgaonkar
2019-06-25 04:54:03 -07:00
committed by Facebook Github Bot
parent 4aafc49aaf
commit cad26c9319
2 changed files with 122 additions and 46 deletions

View File

@@ -76,7 +76,7 @@ function parseJSON(str: string): ?any {
export async function exportMetricsFromTrace(
trace: string,
pluginsMap: Map<string, Class<FlipperDevicePlugin<> | FlipperPlugin<>>>,
): Promise<?string> {
): Promise<string> {
const data = fs.readFileSync(trace, 'utf8');
const parsedJSONData = parseJSON(data);
if (!parsedJSONData) {