Created
August 30, 2011 10:04
-
-
Save glenjamin/1180584 to your computer and use it in GitHub Desktop.
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
var async = require('async'); | |
exports.callPolygen = callPolygen; | |
function callPolygen(grm, callback) { | |
async.waterfall([ | |
function find(next) { | |
findGrm(grm, next); | |
}, | |
function exec(path, next) { | |
execPolygen(path, next); | |
}, | |
function parse(data, next) { | |
parsePolygen(data, callback); | |
} | |
], function error(err) { | |
callback(err); | |
}); | |
} | |
function findGrm(grm, callback) { | |
exec('find . -iname \''+grm+'\.grm\' -type f' , | |
function (err, stdout, stderr) { | |
var path = stdout.replace(/^\s+|\s+$/g,'').split("\n")[0]; | |
callback(err, path); | |
} | |
); | |
} | |
function execPolygen(path, callback) { | |
exec('bin/polygen ' + path, | |
function (error,stdout,stderr){ | |
callback(error, stdout); | |
} | |
); | |
} | |
function parsePolygen(data, callback) { | |
var parsed = HTMLparser.htmlToText(data); | |
callback(null, parsed); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment