Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Write should not use storage directly

  • Loading branch information...
commit 8e8f186d36026498e8cf264c32ae1695fdf302fa 1 parent 3986848
@RStankov RStankov authored
Showing with 8 additions and 19 deletions.
  1. +8 −19 lib/commands.js
View
27 lib/commands.js
@@ -129,26 +129,15 @@ commands.add = function(item) {
* @api public
*/
commands.write = function(filename) {
- var data = '';
- if (!filename) {
- var filename = "~/todo.txt";
- }
- var out = [];
- commands.storage.get('items', function(err, items) {
- items || (items = []);
- for (var i = -1, len = items.length; ++i < len;) {
- if (!app.argv.all && items[i].done) continue;
- out.push(format(items[i], i));
- }
-
- out.push('') && out.unshift('');
- out.map(function(line) {
- console.log(line);
- data += line +"\n";
- });
- fs.writeFile(filename, data, 'utf8', function(err, written) {
- if (err) return console.log(err);
+ filename || (filename = "~/todo.txt");
+
+ commands.todos[app.argv.all ? 'all' : 'undone'](function(items) {
+ var data = commands.format(items);
+
+ commands.print(data);
+ fs.writeFile(filename, data, 'utf8', function(err, written) {
+ if (err) return commands.print(err);
});
});
};
Please sign in to comment.
Something went wrong with that request. Please try again.