Skip to content

Instantly share code, notes, and snippets.

@davglass
Created July 23, 2012 16:21
Show Gist options
  • Save davglass/3164536 to your computer and use it in GitHub Desktop.
Save davglass/3164536 to your computer and use it in GitHub Desktop.
Travis CI checker for Github Projects - Run with ./check.js <username>
#!/usr/bin/env node
var username = process.argv[2],
https = require('https');
if (!username) {
console.error('Please pass a username');
process.exit(1);
}
var get = function(url, cb) {
https.get({
host: 'api.github.com',
path: url
}, function(res) {
var body = '';
res.on('data', function(c) {
body += c;
});
res.on('end', function() {
cb(JSON.parse(body));
});
});
};
var check = function() {
if (counter === repos.length) {
console.log('Found', missing.length, 'repositories without a .travis.yml file');
var m = [];
missing.forEach(function(i) {
m.push(i.repo);
});
console.log(m.join(', '));
}
};
var counter = 0,
repos = [],
missing = [];
console.log('Gathering repo information for', username);
get('/users/' + username + '/repos?per_page=500', function(data) {
data.forEach(function(info) {
if (!info.fork) {
repos.push(info.name);
}
});
console.log('Found', repos.length, 'repositories for', username, ', scanning..');
repos.forEach(function(repo) {
get('/repos/' + username + '/' + repo + '/contents/.travis.yml', (function(repo) {
return function(data) {
if (data.message) {
missing.push({ repo: repo, message: data.message });
}
counter++;
check();
}
}(repo)));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment