Skip to content

Commit 94752db

Browse files
committed
Avoid annoying message in CLI.
1 parent 03126f2 commit 94752db

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

source/cli/plugins/cli_cmd_plugin/source/cli_cmd_plugin.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,19 @@ function command_initialize(plugin_path) {
2020
* };
2121
*/
2222
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+
})();
2436

2537
for (const file of files) {
2638
const file_path = path.join(cmd_path, file);

source/cli/plugins/cli_repl_plugin/source/cli_repl_plugin.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,19 @@ function repl_initialize(plugin_path) {
3636
* plugins/cli/repl/${plugin_name}/${plugin_name}_repl.js
3737
*/
3838
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+
})();
4052

4153
for (const file of files) {
4254
const file_path = path.join(repl_path, file);

0 commit comments

Comments
 (0)