       options.qs.access_token = token
       request options, done
 
-  register 'ci',
+  github.register 'ci',
     cache: 'repository'
     expire: 300
     update: (done) ->

          user: results[1]
          repo: results[2]

  register 'isGitHub',
    update: (done) ->
      github._parseRemoteUrl (err, results) ->
        done err, !!results

  register 'remoteUser',
    update: (done) ->
      github._parseRemoteUrl (err, results) ->
        done err, results?.user

  register 'remoteRepo',
    update: (done) ->
      github._parseRemoteUrl (err, results) ->
        done err, results?.repo

  register 'token',
    update: (done) ->
      process.env.IMPROMPTU_GITHUB_TOKEN


impromptu = require 'impromptu'
git = require 'impromptu-git'

async = require 'async'
read = require 'read'
request = require 'request'

module.exports = impromptu.plugin.create (github) ->
  rGitHubUrl = /^(?:git@github.com:|https:\/\/github.com\/)([^\/]+)\/([^\/]+)\.git/

  github.register '_parseRemoteUrl',
    update: (done) ->
      git.remoteUrl (err, url) ->
        return done err if err
