expose scm

This commit is contained in:
oleg 2016-03-14 21:29:57 +03:00
parent d44071deaf
commit dd4c0c633a

View File

@ -1,6 +1,23 @@
'use strict';
var BaseScm = require('./base').Scm;
exports.BaseScm = BaseScm;
var constructors = {
git: require('./git').Scm,
mercurial: require('./mercurial').Scm
};
exports.register = function(type, constructor) {
constructors[type] = constructor;
};
exports.createScm = function(params) {
var Constructor = require('./' + params.type).Scm;
if (params.type in constructors === false) {
throw new Error('Unknown scm type: ' + params.type);
}
var Constructor = constructors[params.type];
return new Constructor(params);
};