Source taken from https://github.com/darcyclarke/Repo.js/tree/5c0eae0f1b