From dd4c0c633a103c13b144d6d62c450f36a1784540 Mon Sep 17 00:00:00 2001 From: oleg Date: Mon, 14 Mar 2016 21:29:57 +0300 Subject: [PATCH] expose scm --- lib/scm/index.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/scm/index.js b/lib/scm/index.js index 89d0ddc..f68bb6e 100644 --- a/lib/scm/index.js +++ b/lib/scm/index.js @@ -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); };