pass project to the executor constructor

This commit is contained in:
oleg 2015-03-24 00:16:00 +03:00
parent 01a03ec4d7
commit 14b5a968e0
3 changed files with 24 additions and 18 deletions

View File

@ -1,9 +1,12 @@
'use strict';
var Steppy = require('twostep').Steppy;
var Steppy = require('twostep').Steppy,
path = require('path'),
_ = require('underscore');
function Executor(params) {
this.cwd = params.cwd;
this.project = params.project;
this.cwd = path.join(this.project.dir, 'workspace');
}
exports.Executor = Executor;
@ -16,13 +19,14 @@ Executor.prototype._runStep = function(params, callback) {
};
Executor.prototype.run = function(params, callback) {
var self = this;
var self = this,
project = _({}).extend(self.project, params);
Steppy(
function() {
self._getSources(params.scm, this.slot());
self._getSources(project.scm, this.slot());
},
function() {
var funcs = params.steps.map(function(step) {
var funcs = project.steps.map(function(step) {
return function() {
self._runStep(step, this.slot());
};

View File

@ -26,7 +26,8 @@
},
"homepage": "https://github.com/okv/nci",
"dependencies": {
"twostep": "0.4.1"
"twostep": "0.4.1",
"underscore": "1.8.2"
},
"devDependencies": {
"expect.js": "0.3.1",

View File

@ -30,22 +30,23 @@ var expect = require('expect.js'),
it('instance should be created without errors', function() {
executor = createExecutor({
type: type,
cwd: workspacePath
project: {
dir: __dirname,
scm: {
type: 'mercurial',
repository: path.join(__dirname, 'repos', 'mercurial'),
rev: 'default'
},
steps: [
{type: 'shell', cmd: 'echo 1'},
{type: 'shell', cmd: 'echo 2'}
]
}
});
});
it('should run', function(done) {
executor.run({
scm: {
type: 'mercurial',
repository: path.join(__dirname, 'repos', 'mercurial'),
rev: 'default'
},
steps: [
{type: 'shell', cmd: 'echo 1'},
{type: 'shell', cmd: 'echo 2'}
]
}, done);
executor.run({}, done);
});
});
});