From b0551bb74efb64da63e247b72572b679cbd6116a Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Fri, 1 Mar 2019 08:19:27 -0800 Subject: [PATCH] Export Flipper trace along with bug report Summary: Exports Flipper trace along with bug report. I was not able to upload `.flipper` file, thus I have uploaded `.json` file. One can download the json file from the portal and then can rename it to `.flipper` inorder to open it into flipper app. I am looking into downloading `.flipper` directly, instead of `.json`. But that change, if it happens, will be done in other diff. I think having flipper trace on the bug report will be helpful to debug the issues. Reviewed By: danielbuechele Differential Revision: D14266218 fbshipit-source-id: fb7cf4c9773fb355f3569ce8d08b83bd736ab1ca --- src/utils/exportData.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/utils/exportData.js b/src/utils/exportData.js index ae0ffbc1d..a67872833 100644 --- a/src/utils/exportData.js +++ b/src/utils/exportData.js @@ -225,21 +225,31 @@ export async function serializeStore(store: Store): Promise { ); } -export const exportStoreToFile = ( - exportFilePath: string, - store: Store, -): Promise => { +export function exportStore(store: Store): Promise { return new Promise(async (resolve, reject) => { const json = await serializeStore(store); if (!json) { console.error('Make sure a device is connected'); reject('No device is selected'); } - fs.writeFile(exportFilePath, serialize(json), err => { + const serializedString = serialize(json); + if (serializedString.length <= 0) { + reject('Serialize function returned empty string'); + } + resolve(serializedString); + }); +} + +export const exportStoreToFile = ( + exportFilePath: string, + store: Store, +): Promise => { + return exportStore(store).then(storeString => { + fs.writeFile(exportFilePath, storeString, err => { if (err) { - reject(err); + throw new Error(err); } - resolve(); + return; }); }); };