nci/lib/executor/base.js

45 lines
1.0 KiB
JavaScript
Raw Normal View History

'use strict';
var Steppy = require('twostep').Steppy,
path = require('path'),
_ = require('underscore'),
EventEmitter = require('events').EventEmitter,
inherits = require('util').inherits;
function Executor(params) {
this.project = params.project;
this.cwd = path.join(this.project.dir, 'workspace');
}
exports.Executor = Executor;
inherits(Executor, EventEmitter);
Executor.prototype._getSources = function(params, callback) {
};
Executor.prototype._runStep = function(params, callback) {
};
Executor.prototype.run = function(params, callback) {
var self = this,
project = _({}).extend(self.project, params);
Steppy(
function() {
2015-05-05 23:11:28 +00:00
self.emit('currentStep', 'get sources');
self._getSources(project.scm, this.slot());
},
function() {
2015-05-05 23:11:28 +00:00
var funcs = project.steps.map(function(step, index) {
return function() {
2015-05-05 23:11:28 +00:00
self.emit('currentStep', step.name || ('step ' + index));
self._runStep(step, this.slot());
};
});
funcs.push(this.slot());
Steppy.apply(this, funcs);
},
callback
);
};