Last active
February 21, 2020 16:07
-
-
Save njam/03545521a019b19472690fb33463e09f to your computer and use it in GitHub Desktop.
List license of all repos in a Github organisation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var GitHubApi = require('github'); | |
var assert = require('assert'); | |
var org = 'cargomedia'; | |
var token = '<github-token>'; | |
var api = new GitHubApi({ | |
version: '3.0.0', | |
protocol: 'https', | |
headers: {'user-agent': 'repo-lister'} | |
}); | |
api.authenticate({ | |
type: 'oauth', | |
token: token | |
}); | |
api.repos.getFromOrg({org: org, per_page: 9999, headers: {'Accept': 'application/vnd.github.drax-preview+json'}}, function(error, result) { | |
assert.equal(null, error); | |
result.forEach(function(result) { | |
var name = result['name']; | |
var fork = result['fork']; | |
if (!fork) { | |
var license = result['license']; | |
if (result['license']) { | |
license = result['license']['name']; | |
} else { | |
license = 'Closed source'; | |
} | |
console.log('- ' + name + ': ' + license); | |
} | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment