2014-11-25 03:31:20 +00:00
|
|
|
var through = require('through'),
|
|
|
|
canopy = require('canopy');
|
|
|
|
|
|
|
|
module.exports = function(file) {
|
2015-11-01 15:28:37 +00:00
|
|
|
var data = '';
|
|
|
|
|
2014-11-25 03:31:20 +00:00
|
|
|
if (!/\.peg$/.test(file)) {
|
|
|
|
return through();
|
|
|
|
}
|
|
|
|
|
|
|
|
return through(
|
|
|
|
function(buf) {
|
|
|
|
data += buf;
|
|
|
|
},
|
|
|
|
function() {
|
|
|
|
try {
|
|
|
|
this.queue(String(canopy.compile(data)));
|
|
|
|
} catch(err) {
|
|
|
|
this.emit('error', err);
|
|
|
|
}
|
|
|
|
this.queue(null);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|