diff --git a/lib/executor/base.js b/lib/executor/base.js index c76c6c3..3de0f6a 100644 --- a/lib/executor/base.js +++ b/lib/executor/base.js @@ -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()); }; diff --git a/package.json b/package.json index 0aca218..fb3833a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/executor.js b/test/executor.js index 838663f..6032b3c 100644 --- a/test/executor.js +++ b/test/executor.js @@ -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); }); }); });