Skip to content

Showcase

Benjamin Arthur Lupton edited this page Jun 26, 2014 · 12 revisions

A place to showcase the cool chains you've put together

Geojson your github community

http://runnable.com/U6ichlSIeJ8quen5/create-a-geojson-file-for-your-github-communities-for-node-js-and-chainyjs

Get git branches as an array

// Fetch the cwd's branches, and convert them into an array
require('chainy').create().require('set exec log')
	.set('git branch --no-color')
	.exec()
	.action(function(value){
		return value.replace('*', '').replace(/ |^\s+|\s+$/g, '').split('\n');
	})
	.log();

Delete git branches from the remote

// Fetch the cwd's branches, and delete each of them except master from the git remote
require('chainy').create().require('set exec each')
	.set('git branch --no-color')
	.exec()
	.action(function(value){
		return value.replace('*', '').replace(/ /g, '').split('\n').filter(function(value){
			if ( value === 'master' )  return false;
			return true;
		});
	})
	.map(function(value, complete){
		this.create()
			.exec(function(){
				return 'git push origin :'+value;
			})
			.done(complete)
	})