File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 1515const fs = require ( 'fs' ) ;
1616const 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
You can’t perform that action at this time.
0 commit comments