From 067e0d726920246d643e4e03d9067d76e52d35a7 Mon Sep 17 00:00:00 2001 From: saar-IL Date: Sat, 18 Apr 2026 18:54:02 +0300 Subject: [PATCH] Update flatten-and-resolve.js --- hack/flatten-and-resolve.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/hack/flatten-and-resolve.js b/hack/flatten-and-resolve.js index 04532d343eb5..ad6a9ebc23ae 100755 --- a/hack/flatten-and-resolve.js +++ b/hack/flatten-and-resolve.js @@ -15,10 +15,22 @@ const fs = require('fs'); const path = require('path'); -const PUBLIC_DIR = path.resolve(process.argv[2] || 'public'); +const inputDir = process.argv[2] ?? 'public'; +const PUBLIC_DIR = path.resolve(process.cwd(), inputDir); -if (!fs.existsSync(PUBLIC_DIR)) { - console.error(`Error: Directory ${PUBLIC_DIR} does not exist`); +try { + const stat = fs.statSync(PUBLIC_DIR); + + if (!stat.isDirectory()) { + console.error(`Error: ${PUBLIC_DIR} is not a directory`); + process.exit(1); + } +} catch (err) { + if (err.code === 'ENOENT') { + console.error(`Error: Directory ${PUBLIC_DIR} does not exist`); + } else { + console.error(`Error accessing ${PUBLIC_DIR}:`, err.message); + } process.exit(1); }