Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var getProject = function(params, callback) {
var project;
Steppy(
function() {
project = _(app.projects).findWhere(params.condition);
getAvgProjectBuildDuration(project.name, this.slot());
// get last done build
db.builds.find({
start: {
projectName: project.name,
status: 'done',
descCreateDate: ''
},
limit: 1
}, this.slot());
// tricky but effective streak counting inside filter goes below
Distributor.prototype._updateBuild = function(build, changes, callback) {
var self = this;
callback = callback || _.noop;
var originalBuild = _(build).clone();
Steppy(
function() {
if (build.id && changes.status && changes.status !== build.status) {
logger.log(
'Build #%s (project "%s", env: %s) change status: %s -> %s',
build.id,
build.project.name,
build.env ? build.env.name : 'not set',
build.status,
changes.status
);
}
_(build).extend(changes);
// skip saving to db of unimportant data
if (changes.currentStep && _(changes).keys().length === 1) {
Notifier.prototype.send = function(build, callback) {
callback = callback || function(err) {
if (err) {
logger.error('Error during send:', err.stack || err);
}
};
var self = this;
Steppy(
function() {
if (!build.completed) {
throw new Error('Build should be completed before notify');
}
var notify = build.project.notify;
// TODO: move to project validation during load
if (!notify || !notify.on || !notify.to) {
return callback();
}
this.pass(notify);
// get previous build (for some strategies)
if (_(notify.on).intersection(['change', 'fix']).length) {
Distributor.prototype.cancel = function(params, callback) {
callback = callback || function(err) {
if (err) logger.error('Error during cancel: ', err.stack || err);
};
var self = this,
id = params.buildId;
Steppy(
function() {
var queueItemIndex = _(self.queue).findIndex(function(item) {
return item.build.id === id;
});
var build;
// cancel queued build
if (queueItemIndex !== -1) {
build = self.queue[queueItemIndex].build;
// remove from queue
self.queue.splice(queueItemIndex, 1);
// remove from db
self.removeBuild(build, this.slot());
// separate params
if (!_(params).isObject()) {
params = {
name: arguments[0],
newName: arguments[1]
};
callback = arguments[2];
}
callback = callback || _.noop;
var self = this,
name = params.name,
newName = params.newName,
project;
Steppy(
function() {
if (!name) {
throw new Error('Project name is required');
}
if (!newName) {
throw new Error('Project new name is required');
}
project = self.get(name);
if (!project) {
throw new Error('Can`t find project "' + name + '" for rename');
}
self.unload({name: name}, this.slot());
resource.use('readAll', function(req, res, next) {
Steppy(
function() {
var data = req.data || {},
getParams = {limit: data.limit || 20};
if (data.projectName) {
getParams.projectName = data.projectName;
}
app.builds.getRecent(getParams, this.slot());
},
function(err, builds) {
// omit big fields not needed for list
_(builds).each(function(build) {
delete build.stepTimings;
if (build.scm) {
delete build.scm.changes;
it('should run both projects without errors', function(done) {
Steppy(
function() {
distributor.run({projectName: 'project1'}, this.slot());
distributor.run({projectName: 'project2'}, this.slot());
},
function(err) {
expect(err).not.ok();
this.pass(null);
},
done
);
});
it('should be set "true" by default', function(done) {
Steppy(
function() {
collection.findOneAndDelete(condition, this.slot());
},
function(err, result) {
expect(result).not.ok();
expect(result).equal(null);
this.pass(null);
},
done
);
});
it('should be set true by default', function(done) {
Steppy(
function() {
collection.deleteOne(condition, this.slot());
},
function(err, result) {
expect(result).ok();
expect(result).only.keys('deletedCount');
this.pass(null);
},
done
);
});
before(function(done) {
Steppy(
function() {
collection = helpers.getCollection();
collection.insertOne(entity, this.slot());
},
done
);
});