blob: 8e03ea17b4a2c437580bdd4c5a2c2c70c1f95a09 [file] [log] [blame]
var through2 = require('through2');
module.exports = transform;
/*
* A list of specialist transformers targetting specific filetypes.
*/
var transformers = Object.freeze([
require('./css-transform'),
require('./md-transform')
]);
/*
* Apply a transform to any given file. Most files are simply passed through,
* but a matching specialist transformer applies its transform function instead.
*/
function transform(file) {
// Attempt to find a specialist transformer to apply their transformation.
for (var i = 0; i < transformers.length; i++) {
if (transformers[i].canTransform(file)) {
return transformers[i].transform(file);
}
}
// If there's no result, pass the file through normally.
return through2();
}