-#
-# pkgmgr.coffee
-#
+# Install packages from GitHub repos.
 
 fs = require 'fs-extra'
 sysPath = require 'path'
-logging = require './utils/logging'
-project = require './project'
 Emitter = require('events').EventEmitter
 async = require 'async'
 _ = require 'underscore'
+project = require './project'
+logging = require './utils/logging'
 request = require './utils/request'
 
 # In-flight requests
 inFlight = {}
 
-# Package class
+# Package
 class Package extends Emitter
-  constructor: (@repo, version, options) ->
+
+  constructor: (@repo, version) ->
+    # The second argument could be a version number or an pkgInfo hash.
     if _.isObject(version)
       @pkgInfo = version
       @version = @pkgInfo.version

      else
        @emit 'end'


install = (repo, version='master') ->
  pkg = new Package(repo, version)
  pkg.install()

module.exports = {install}

    else
      @version = version

    # The default version is `master`.
    @version = 'master' if not @version or @version is '*'
    logging.info "Installing #{@repo}@#{@version}..."

    @remote = 'https://raw.github.com'
    @slug = "#{@repo}@#{@version}"

    # Use `repo@version` to de-duplicate in-flight requests.
    if inFlight[@slug]
      @install = @emit.bind(@, 'end')
    inFlight[@slug] = true
