Skip to content

Instantly share code, notes, and snippets.

@glenjamin
Created August 30, 2011 10:04
Show Gist options
  • Save glenjamin/1180584 to your computer and use it in GitHub Desktop.
Save glenjamin/1180584 to your computer and use it in GitHub Desktop.
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