From feb20afa9e689523759faf5a3a571da46cc8c6fc Mon Sep 17 00:00:00 2001 From: Rushikesh Tote Date: Fri, 17 Jun 2022 12:00:15 +0530 Subject: [PATCH] fix bug where paths can be undefined --- src/services/fs.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/services/fs.ts b/src/services/fs.ts index 4bb8229f9..0013e4bce 100644 --- a/src/services/fs.ts +++ b/src/services/fs.ts @@ -70,15 +70,18 @@ export async function getElectronFile(filePath: string): Promise { }; } -export const getValidPaths = (paths: string[]) => - paths.filter(async (path) => { +export const getValidPaths = (paths: string[]) => { + if (!paths) { + return [] as string[]; + } + return paths.filter(async (path) => { try { await fs.stat(path).then((stat) => stat.isFile()); } catch (e) { return false; } }); - +}; export const getZipFileStream = async ( zip: StreamZip.StreamZipAsync, filePath: string