mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-10 17:39:15 +00:00
pass project to the executor constructor
This commit is contained in:
parent
01a03ec4d7
commit
14b5a968e0
@ -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());
|
||||
};
|
||||
|
@ -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",
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user