File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,19 @@ function command_initialize(plugin_path) {
20
20
* };
21
21
*/
22
22
const cmd_path = path . join ( plugin_path , 'cli' , 'cmd' ) ;
23
- const files = fs . readdirSync ( cmd_path ) ;
23
+ const files = ( ( ) => {
24
+ try {
25
+ return fs . readdirSync ( cmd_path ) ;
26
+ } catch ( e ) {
27
+ /* If the directory does not exist, return no files */
28
+ if ( e ?. code === 'ENOENT' ) {
29
+ return [ ]
30
+ }
31
+
32
+ /* Otherwise, rethrow the exception */
33
+ throw e ;
34
+ }
35
+ } ) ( ) ;
24
36
25
37
for ( const file of files ) {
26
38
const file_path = path . join ( cmd_path , file ) ;
Original file line number Diff line number Diff line change @@ -36,7 +36,19 @@ function repl_initialize(plugin_path) {
36
36
* plugins/cli/repl/${plugin_name}/${plugin_name}_repl.js
37
37
*/
38
38
const repl_path = path . join ( plugin_path , 'cli' , 'repl' ) ;
39
- const files = fs . readdirSync ( repl_path ) ;
39
+ const files = ( ( ) => {
40
+ try {
41
+ return fs . readdirSync ( repl_path ) ;
42
+ } catch ( e ) {
43
+ /* If the directory does not exist, return no files */
44
+ if ( e ?. code === 'ENOENT' ) {
45
+ return [ ]
46
+ }
47
+
48
+ /* Otherwise, rethrow the exception */
49
+ throw e ;
50
+ }
51
+ } ) ( ) ;
40
52
41
53
for ( const file of files ) {
42
54
const file_path = path . join ( repl_path , file ) ;
You can’t perform that action at this time.
0 commit comments