refactor: improve bots/todo-* (#41)

This commit is contained in:
sigoden
2024-06-10 19:57:37 +08:00
committed by GitHub
parent 8f3385ca9e
commit 7225ee331a
4 changed files with 8 additions and 21 deletions
+2 -7
View File
@@ -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);
}