Created
February 16, 2015 13:26
-
-
Save charlieanstey/9259633e8163dde29fa3 to your computer and use it in GitHub Desktop.
Trello :: Export JSON to console using Node.js
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
'use strict'; | |
var readline = require('readline'); | |
// ------------------ | |
function TrelloJsonExport() {} | |
TrelloJsonExport.prototype.outputComments = function(json) { | |
json = JSON.parse(json); | |
var comments = json.actions.filter(isCommentCard); | |
comments.reverse(); | |
console.log('\nCOMMENTS START\n') | |
for(var i = 0; i < comments.length; i++) { | |
console.log(comments[i].data.text + '\n'); | |
} | |
process.exit(); | |
} | |
// Filter for comment cards | |
function isCommentCard(element, index, array) { | |
return element.type == 'commentCard'; | |
} | |
// ------------------ | |
var rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
var trello = new TrelloJsonExport(); | |
rl.question('Enter Trello JSON:', trello.outputComments); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment