merge with master

This commit is contained in:
oleg 2016-03-08 22:50:22 +03:00
commit e219ebfc79
6 changed files with 32 additions and 13 deletions

View File

@ -1,9 +0,0 @@
scm:
type: git
repository: /Users/vladimir/projects/fit/culture/frontend_node
rev: master
steps:
sync: npm run sync
test: nrun test -R dot
pack: nrun packSafe

View File

@ -30,6 +30,8 @@ Command.prototype.run = function(params, callback) {
stdout = self.collectOut ? '' : null,
stderr = self.attachStderr ? '' : null;
callback = _(callback).once();
if (!params.cmd) return callback(new Error('`cmd` is not set'));
if (!params.args) return callback(new Error('`args` is not set'));
params.options = params.options || {};
@ -41,6 +43,16 @@ Command.prototype.run = function(params, callback) {
self.emit('stdin', params.cmd + ' ' + params.args.join(' ') + '\n');
}
var extendError = function (err) {
err.message = (
'Error while spawn "' +
[params.cmd].concat(params.args || []).join(' ') + '": ' +
err.message
);
return err;
};
cmd.stdout.on('data', function(data) {
if (self.emitOut) self.emit('stdout', data);
if (self.collectOut) stdout += data;
@ -54,11 +66,17 @@ Command.prototype.run = function(params, callback) {
cmd.on('close', function(code) {
var err = null;
if (code !== 0) {
err = new Error('Spawned command exits with non-zero code: ' + code);
err = extendError(
new Error('Spawned command exits with non-zero code: ' + code)
);
err.stderr = stderr;
}
callback(err, stdout);
});
cmd.on('error', function(err) {
callback(extendError(err));
});
return cmd;
};

View File

@ -172,5 +172,14 @@ Scm.prototype.getChanges = function(rev1, rev2, callback) {
};
Scm.prototype.update = function(rev, callback) {
this._run({cmd: 'git', args: ['checkout', '-f', rev]}, callback);
var self = this;
Steppy(
function() {
self._run({cmd: 'git', args: ['checkout', '-f', rev]}, this.slot());
},
function() {
self._run({cmd: 'git', args: ['submodule', 'update']}, this.slot());
},
callback
);
};

View File

@ -3,6 +3,7 @@
"ignore": [
"data",
"node_modules/*/node_modules/",
"node_modules/nci-classic-ui/app/",
"node_modules/nci-classic-ui/static/"
],
"watch": "./"

View File

@ -1,6 +1,6 @@
{
"name": "nci",
"version": "0.9.2",
"version": "0.9.4",
"description": "Flexible, open source continuous integration server written in node.js",
"bin": {
"nci": "bin/nci"

View File

@ -44,7 +44,7 @@ describe('Shell command', function() {
// messages and codes are slightly different across the OSes
// e.g. at linux and macos
expect(err.message).match(
/^Spawned command exits with non-zero code: \d+/
/Spawned command exits with non-zero code: \d+/
);
expect(err.stderr).match(/echo1:.*not found/);
expect(std.err).equal('');