Created
February 16, 2015 20:06
-
-
Save gre/37ea8a269567aeb74840 to your computer and use it in GitHub Desktop.
This file contains 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 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