3 var fs = require('fs');
4 var path = require('path');
6 module.exports = function(serializerDirectory) {
8 serialize: require('gitter-web-serialization/lib/serialize'),
9 serializeObject: require('gitter-web-serialization/lib/serialize-object')
12 fs.readdirSync(__dirname + '/' + serializerDirectory).forEach(function(fileName) {
13 if (!/\.js$/.test(fileName)) return;
15 var baseName = path.basename(fileName, '.js');
17 var strategyName = baseName
18 .replace(/\-./g, function(match) {
19 return match[1].toUpperCase();
21 .replace(/^./, function(match) {
22 return match.toUpperCase();
25 var Strategy = require('./' + serializerDirectory + '/' + baseName);
26 if (Strategy.prototype) {
27 Strategy.prototype.strategyType = serializerDirectory; // Not ideal
30 e[strategyName] = Strategy;