don't throw error

This commit is contained in:
Abhinav 2023-02-07 16:02:10 +05:30
parent 3287ae587e
commit 4c695f83c6

View file

@ -188,16 +188,17 @@ export async function isFolder(dirPath: string) {
const stats = await fs.stat(dirPath);
return stats.isDirectory();
} catch (e) {
let err = e;
// if code is defined, it's an error from fs.stat
if (typeof e.code !== 'undefined') {
// ENOENT means the file does not exist
if (e.code === 'ENOENT') {
return false;
}
throw Error(`fs error code: ${e.code}`);
} else {
throw e;
err = Error(`fs error code: ${e.code}`);
}
logError(err, 'isFolder failed');
return false;
}
}