mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-11 09:09:15 +00:00
pass project to the executor constructor
This commit is contained in:
parent
01a03ec4d7
commit
14b5a968e0
@ -1,9 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var Steppy = require('twostep').Steppy;
|
var Steppy = require('twostep').Steppy,
|
||||||
|
path = require('path'),
|
||||||
|
_ = require('underscore');
|
||||||
|
|
||||||
function Executor(params) {
|
function Executor(params) {
|
||||||
this.cwd = params.cwd;
|
this.project = params.project;
|
||||||
|
this.cwd = path.join(this.project.dir, 'workspace');
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.Executor = Executor;
|
exports.Executor = Executor;
|
||||||
@ -16,13 +19,14 @@ Executor.prototype._runStep = function(params, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Executor.prototype.run = function(params, callback) {
|
Executor.prototype.run = function(params, callback) {
|
||||||
var self = this;
|
var self = this,
|
||||||
|
project = _({}).extend(self.project, params);
|
||||||
Steppy(
|
Steppy(
|
||||||
function() {
|
function() {
|
||||||
self._getSources(params.scm, this.slot());
|
self._getSources(project.scm, this.slot());
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
var funcs = params.steps.map(function(step) {
|
var funcs = project.steps.map(function(step) {
|
||||||
return function() {
|
return function() {
|
||||||
self._runStep(step, this.slot());
|
self._runStep(step, this.slot());
|
||||||
};
|
};
|
||||||
|
@ -26,7 +26,8 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/okv/nci",
|
"homepage": "https://github.com/okv/nci",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"twostep": "0.4.1"
|
"twostep": "0.4.1",
|
||||||
|
"underscore": "1.8.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"expect.js": "0.3.1",
|
"expect.js": "0.3.1",
|
||||||
|
@ -30,22 +30,23 @@ var expect = require('expect.js'),
|
|||||||
it('instance should be created without errors', function() {
|
it('instance should be created without errors', function() {
|
||||||
executor = createExecutor({
|
executor = createExecutor({
|
||||||
type: type,
|
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) {
|
it('should run', function(done) {
|
||||||
executor.run({
|
executor.run({}, done);
|
||||||
scm: {
|
|
||||||
type: 'mercurial',
|
|
||||||
repository: path.join(__dirname, 'repos', 'mercurial'),
|
|
||||||
rev: 'default'
|
|
||||||
},
|
|
||||||
steps: [
|
|
||||||
{type: 'shell', cmd: 'echo 1'},
|
|
||||||
{type: 'shell', cmd: 'echo 2'}
|
|
||||||
]
|
|
||||||
}, done);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user