Skip to content

Commit 067e0d7

Browse files
authored
Update flatten-and-resolve.js
1 parent d131957 commit 067e0d7

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

hack/flatten-and-resolve.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,22 @@
1515
const fs = require('fs');
1616
const path = require('path');
1717

18-
const PUBLIC_DIR = path.resolve(process.argv[2] || 'public');
18+
const inputDir = process.argv[2] ?? 'public';
19+
const PUBLIC_DIR = path.resolve(process.cwd(), inputDir);
1920

20-
if (!fs.existsSync(PUBLIC_DIR)) {
21-
console.error(`Error: Directory ${PUBLIC_DIR} does not exist`);
21+
try {
22+
const stat = fs.statSync(PUBLIC_DIR);
23+
24+
if (!stat.isDirectory()) {
25+
console.error(`Error: ${PUBLIC_DIR} is not a directory`);
26+
process.exit(1);
27+
}
28+
} catch (err) {
29+
if (err.code === 'ENOENT') {
30+
console.error(`Error: Directory ${PUBLIC_DIR} does not exist`);
31+
} else {
32+
console.error(`Error accessing ${PUBLIC_DIR}:`, err.message);
33+
}
2234
process.exit(1);
2335
}
2436

0 commit comments

Comments
 (0)