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