From 7225ee331a82cf1f8d8afab8923c4f35a792e5b8 Mon Sep 17 00:00:00 2001 From: sigoden Date: Mon, 10 Jun 2024 19:57:37 +0800 Subject: refactor: improve bots/todo-* (#41) --- bots/todo-js/tools.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'bots/todo-js/tools.js') diff --git a/bots/todo-js/tools.js b/bots/todo-js/tools.js index ed3ed39..0c9db49 100644 --- a/bots/todo-js/tools.js +++ b/bots/todo-js/tools.js @@ -34,7 +34,7 @@ exports.del_todo = function delTodo(args) { fs.writeFileSync(todosFile, JSON.stringify(newData)); console.log(`Successfully deleted todo id=${args.id}`); } else { - _die('Empty todo list'); + console.log('Empty todo list'); } } @@ -46,7 +46,7 @@ exports.list_todos = function listTodos() { if (fs.existsSync(todosFile)) { console.log(fs.readFileSync(todosFile, "utf8")); } else { - _die('Empty todo list'); + console.log("[]"); } } @@ -66,8 +66,3 @@ function _getTodosFile() { } return path.join(cacheDir, 'todos.json'); } - -function _die(message) { - console.error(message); - process.exit(1); -} \ No newline at end of file -- cgit v1.2.3