expose command, executor, node and scm to api

This commit is contained in:
oleg 2016-02-29 23:53:42 +03:00
parent 2a7d6dfb98
commit 4304cd009e
4 changed files with 22 additions and 2 deletions

8
app.js
View File

@ -16,6 +16,10 @@ var env = process.env.NODE_ENV || 'development',
ProjectsCollection = require('./lib/project').ProjectsCollection,
BuildsCollection = require('./lib/build').BuildsCollection,
libLogger = require('./lib/logger'),
libNode = require('./lib/node'),
libCommand = require('./lib/command'),
libExecutor = require('./lib/executor'),
libScm = require('./lib/scm'),
EventEmitter = require('events').EventEmitter,
validateConfig = require('./lib/validateConfig'),
utils = require('./lib/utils');
@ -64,6 +68,10 @@ app.lib = {};
app.lib.BaseReaderLoader = BaseReaderLoader;
app.lib.BaseNotifierTransport = BaseNotifierTransport;
app.lib.logger = libLogger;
app.lib.command = libCommand;
app.lib.executor = libExecutor;
app.lib.scm = libScm;
app.lib.node = libNode;
var configDefaults = {
notify: {},

View File

@ -1,5 +1,9 @@
'use strict';
var SpawnCommand = require('./spawn').Command;
exports.SpawnCommand = SpawnCommand;
exports.createCommand = function(params) {
var Constructor = require('./' + params.type).Command;
return new Constructor(params);

View File

@ -1,5 +1,9 @@
'use strict';
var BaseExecutor = require('./base').Executor;
exports.BaseExecutor = BaseExecutor;
exports.createExecutor = function(params) {
var Constructor = require('./' + params.type).Executor;
return new Constructor(params);

View File

@ -1,16 +1,20 @@
'use strict';
var BaseNode = require('./base').Node;
exports.BaseNode = BaseNode;
var constructors = {
local: require('./local').Node
};
exports.register = function(type, constructor) {
constructor[type] = constructor;
constructors[type] = constructor;
};
exports.createNode = function(params) {
if (params.type in constructors === false) {
throw new Error('Unknown node type: ', params.type);
throw new Error('Unknown node type: ' + params.type);
}
var Constructor = constructors[params.type];