nci/lib/scm/index.js

24 lines
487 B
JavaScript
Raw Normal View History

'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);
};