Last active
August 29, 2015 14:19
-
-
Save Robert-Wett/74c64facfdd51b882961 to your computer and use it in GitHub Desktop.
Simple TODO logger in node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "todo", | |
"version": "1.0.0", | |
"description": "simple todo utility for fire and forget TODO items with a timestamp", | |
"main": "todo.js", | |
"author": "robert-wett", | |
"license": "ISC", | |
"dependencies": { | |
"commander": "^2.8.0", | |
"moment": "^2.10.2" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var program = require( 'commander' ); | |
var fs = require( 'fs' ); | |
var moment = require( 'moment' ); | |
var LOG_FILE = './log.txt'; | |
var DATE_SEP = ' ~~~> '; | |
program.parse( process.argv ); | |
var input = program.args.slice().join(' '); | |
if ( !input ) { | |
return; | |
} | |
var entry = moment().toString() + DATE_SEP + input + '\n'; | |
fs.appendFile( LOG_FILE, entry, function( err ) { | |
if ( err ) { | |
console.log( "fuck you pal, I don't know how to do this" ); | |
console.log( err.stack ); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment