2014-05-09 23:27:35 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-03-14 18:29:57 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2014-12-02 21:09:05 +00:00
|
|
|
exports.createScm = function(params) {
|
2016-03-14 18:29:57 +00:00
|
|
|
if (params.type in constructors === false) {
|
|
|
|
throw new Error('Unknown scm type: ' + params.type);
|
|
|
|
}
|
|
|
|
|
|
|
|
var Constructor = constructors[params.type];
|
2014-12-02 21:09:05 +00:00
|
|
|
return new Constructor(params);
|
2014-05-09 23:27:35 +00:00
|
|
|
};
|