Add try catch

This commit is contained in:
Gal 2024-02-14 21:58:24 +01:00
parent e35a9119a9
commit 7822c38e99
Signed by: gal
GPG Key ID: F035BC65003BC00B
1 changed files with 7 additions and 0 deletions

View File

@ -23,6 +23,13 @@ import { promises as fs } from 'fs';
async function compressImages(inputDir, outputDir) {
console.log(`Reading images from ${inputDir}`);
try {
await fs.stat(inputDir);
} catch (error: unknown) {
console.error(`Error checking input directory: ${(error as Error).message}`);
return;
}
const files = await glob(`**/*.{jpg,png}`, inputDir);
console.log(`Found ${files.length} files:`);