Skip to content

Commit

Permalink
Avoid annoying message in CLI.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Oct 29, 2024
1 parent 03126f2 commit 94752db
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
14 changes: 13 additions & 1 deletion source/cli/plugins/cli_cmd_plugin/source/cli_cmd_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,19 @@ function command_initialize(plugin_path) {
* };
*/
const cmd_path = path.join(plugin_path, 'cli', 'cmd');
const files = fs.readdirSync(cmd_path);
const files = (() => {
try {
return fs.readdirSync(cmd_path);
} catch (e) {
/* If the directory does not exist, return no files */
if (e?.code === 'ENOENT') {
return []
}

/* Otherwise, rethrow the exception */
throw e;
}
})();

for (const file of files) {
const file_path = path.join(cmd_path, file);
Expand Down
14 changes: 13 additions & 1 deletion source/cli/plugins/cli_repl_plugin/source/cli_repl_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,19 @@ function repl_initialize(plugin_path) {
* plugins/cli/repl/${plugin_name}/${plugin_name}_repl.js
*/
const repl_path = path.join(plugin_path, 'cli', 'repl');
const files = fs.readdirSync(repl_path);
const files = (() => {
try {
return fs.readdirSync(repl_path);
} catch (e) {
/* If the directory does not exist, return no files */
if (e?.code === 'ENOENT') {
return []
}

/* Otherwise, rethrow the exception */
throw e;
}
})();

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

0 comments on commit 94752db

Please sign in to comment.