Skip to content

Instantly share code, notes, and snippets.

@balupton balupton/script.js
Created Jun 25, 2014

What would you like to do?
Chainy: Update base files for all repos of multiple github organisations
var util = require('util')
require('chainy').create().require('feed set map exec')
.set(['bevry', 'docpad'])
.addExtension('pagefeed', 'action', function(url, opts, next){
url = url.replace('PER_PAGE', opts.per_page).replace('PAGE',
var chain = this
var results = []
var fetch = function(page){
.done(function(err, result){
// Did we fail requesting the result
if ( err ) return next(err)
// Do we want to get the results specially?
try {
if ( opts.getResult ) result = opts.getResult(result)
} catch (err) {
return next(err)
// Was the results actually an error?
if ( util.isError(result) ) {
return next(result)
if ( Array.isArray(result) === false ) {
err = new Error('result was of an unexpected format')
return next(err)
// Result is as expected, push it the results queue
results.push.apply(results, result)
// We do not have more results
if ( result.length !== opts.per_page ) return next(null, result)
// We do have more results
else repeat(page+1)
// fetch org repos in parallel
.map(function(org, next){
per_page: 100,
page: 1
}, {concurrency:0})
// convert an array of org repos, to an array of repos
// do our business on them
.each(function(repo, next){
// clone it out
.set('git clone '+repo.clone_url)
// update base files
// restore custom entries in .npmignore, .gitignore, and
// add new badges
// npm install projectz
// run projects compile
// commit it back
// push it up as a pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.