       writeStream.on 'finish', -> callback(null, imagePath)
       writeStream.on 'error', (error) -> callback(error)
 
+      request ?= require 'request'
       readStream = request("https://github.com/#{login}.png")
       readStream.on 'error', (error) -> callback(error)
       readStream.pipe(writeStream)

    path.join @getCachePath(), "#{login}-#{Date.now()}"

  cachedAvatar: (login, callback) ->
    glob @avatarGlob(login), (err, files) =>
      files.sort().reverse()
      for imagePath in files

fs = require 'fs-plus'
path = require 'path'

glob = null    # defer until used
request = null # defer until used

module.exports =
class AtomIoClient
