fix bug where paths can be undefined

This commit is contained in:
Rushikesh Tote 2022-06-17 12:00:15 +05:30 committed by Abhinav
parent 2133727652
commit feb20afa9e

View file

@ -70,15 +70,18 @@ export async function getElectronFile(filePath: string): Promise<ElectronFile> {
};
}
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