diff --git a/headless/index.js b/headless/index.js index f74614d2b..0661824a9 100644 --- a/headless/index.js +++ b/headless/index.js @@ -13,7 +13,7 @@ import path from 'path'; // $FlowFixMe this file exist, trust me, flow! import setup from '../static/setup.js'; import yargs from 'yargs'; -import {serializeStore} from '../src/utils/exportData.js'; +import {exportStore} from '../src/utils/exportData.js'; yargs .usage('$0 [args]') @@ -98,7 +98,7 @@ function startFlipper({ dispatcher(store, logger); process.on('SIGINT', async () => { - originalConsole.log(JSON.stringify(await serializeStore(store), null, 2)); + originalConsole.log(await exportStore(store)); process.exit(); }); } diff --git a/src/utils/exportData.js b/src/utils/exportData.js index 034b8fda5..8ed33d332 100644 --- a/src/utils/exportData.js +++ b/src/utils/exportData.js @@ -178,7 +178,7 @@ export const processStore = ( return null; }; -export async function serializeStore(store: Store): Promise { +export async function getStoreExport(store: Store): Promise { const state = store.getState(); const {clients} = state.connections; const {pluginStates} = state; @@ -232,12 +232,12 @@ export async function serializeStore(store: Store): Promise { export function exportStore(store: Store): Promise { getLogger().track('usage', EXPORT_FLIPPER_TRACE_EVENT); return new Promise(async (resolve, reject) => { - const json = await serializeStore(store); - if (!json) { + const storeExport = await getStoreExport(store); + if (!storeExport) { console.error('Make sure a device is connected'); reject('No device is selected'); } - const serializedString = serialize(json); + const serializedString = serialize(storeExport); if (serializedString.length <= 0) { reject('Serialize function returned empty string'); }