mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-11 08:05:07 +00:00
generate step labels from cmd
This commit is contained in:
parent
94629bd27e
commit
a6ff3b4f62
@ -67,8 +67,8 @@ Distributor.prototype._runNext = function(callback) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
executor.on('currentStep', function(stepName) {
|
executor.on('currentStep', function(stepLabel) {
|
||||||
build.currentStep = stepName;
|
build.currentStep = stepLabel;
|
||||||
self._updateBuild(build);
|
self._updateBuild(build);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4,7 +4,8 @@ var Steppy = require('twostep').Steppy,
|
|||||||
path = require('path'),
|
path = require('path'),
|
||||||
_ = require('underscore'),
|
_ = require('underscore'),
|
||||||
EventEmitter = require('events').EventEmitter,
|
EventEmitter = require('events').EventEmitter,
|
||||||
inherits = require('util').inherits;
|
inherits = require('util').inherits,
|
||||||
|
utils = require('../utils');
|
||||||
|
|
||||||
function Executor(params) {
|
function Executor(params) {
|
||||||
this.project = params.project;
|
this.project = params.project;
|
||||||
@ -33,7 +34,8 @@ Executor.prototype.run = function(params, callback) {
|
|||||||
function() {
|
function() {
|
||||||
var funcs = project.steps.map(function(step, index) {
|
var funcs = project.steps.map(function(step, index) {
|
||||||
return function() {
|
return function() {
|
||||||
self.emit('currentStep', step.name || ('step ' + index));
|
var stepLabel = step.name || utils.prune(step.cmd, 15);
|
||||||
|
self.emit('currentStep', stepLabel);
|
||||||
self._runStep(step, this.slot());
|
self._runStep(step, this.slot());
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
11
lib/utils.js
11
lib/utils.js
@ -22,3 +22,14 @@ exports.once = function(func) {
|
|||||||
isCalled = true;
|
isCalled = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.prune = function(str, length) {
|
||||||
|
var result = '',
|
||||||
|
words = str.split(' ');
|
||||||
|
|
||||||
|
do {
|
||||||
|
result += words.shift() + ' ';
|
||||||
|
} while (words.length && result.length < length);
|
||||||
|
|
||||||
|
return result.replace(/ $/, result.length <= length ? '' : '...');
|
||||||
|
};
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
"rev": "default"
|
"rev": "default"
|
||||||
},
|
},
|
||||||
"steps": [
|
"steps": [
|
||||||
{"type": "shell", "cmd": "echo \"hello, cur dir is `pwd`\""},
|
{"type": "shell", "cmd": "sleep 2 && echo \"hello, cur dir is `pwd`\""},
|
||||||
{"type": "shell", "name": "sleep", "cmd": "sleep 4"},
|
{"type": "shell", "name": "sleep", "cmd": "sleep 4"},
|
||||||
{"type": "shell", "cmd": "echo 1 > 1.txt"},
|
{"type": "shell", "cmd": "echo 1 > 1.txt"},
|
||||||
{"type": "shell", "cmd": "sleep 4"},
|
{"type": "shell", "cmd": "sleep 4"},
|
||||||
|
Loading…
Reference in New Issue
Block a user