How to use twostep - 10 common examples

To help you get started, we’ve selected a few twostep examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-ci / nci / resources / projects.js View on Github external
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
github node-ci / nci / lib / distributor.js View on Github external
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) {
github node-ci / nci / lib / notifier / index.js View on Github external
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) {
github node-ci / nci / lib / distributor.js View on Github external
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());
github node-ci / nci / lib / project.js View on Github external
// 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());
github node-ci / nci / resources / builds.js View on Github external
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;
github node-ci / nci / test / distributor / blocking.js View on Github external
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
			);
		});
github 2do2go / mongodbext / test / findOneAndDelete.js View on Github external
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
			);
		});
github 2do2go / mongodbext / test / deleteOne.js View on Github external
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
			);
		});
github 2do2go / mongodbext / test / updateOne.js View on Github external
before(function(done) {
			Steppy(
				function() {
					collection = helpers.getCollection();

					collection.insertOne(entity, this.slot());
				},
				done
			);
		});

twostep

Simple control-flow library for node.js that makes parallel execution, serial execution and error handling painless.

MIT
Latest version published 8 years ago

Package Health Score

47 / 100
Full package analysis

Popular twostep functions