Skip to content

Instantly share code, notes, and snippets.

@gre
Created February 16, 2015 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gre/37ea8a269567aeb74840 to your computer and use it in GitHub Desktop.
Save gre/37ea8a269567aeb74840 to your computer and use it in GitHub Desktop.
var through = require("through")
var extract = require("glsl-extract")
require("glsl-transitions").forEach(function (t) {
var e=null;
console.error = function (msg) {
e = msg;
};
getExports(t.glsl); // for some reason this doesn't break but log using console.error (so I hacked console.error!)
if (e) {
console.log("\n");
console.log(e);
console.log("GLSL:", t.glsl);
}
});
function getExports(source) {
var exports
var stream = through()
var nextTick = process.nextTick
var stack = []
process.nextTick = function(f) {
stack.push(f)
}
extract(stream)(function onExtractComplete(err, info) {
if(err) {
throw err
}
exports = info
})
stream.end(new Buffer(source, "utf-8"))
for(var i=0; i<stack.length; ++i) {
var f = stack[i]
try {
f()
} catch(e) {
console.error(e)
}
}
process.nextTick = nextTick
return exports
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment