 yargs = require 'yargs'
 read = require 'read'
 semver = require 'npm/node_modules/semver'
+Git = require 'git-utils'
 
 Command = require './command'
 config = require './apm'

    for {pack, latestVersion} in updates
      do (pack, latestVersion) ->
        installCommands.push (callback) ->
          commandArgs = ["#{pack.name}@#{latestVersion}"]
          commandArgs.unshift('--verbose') if verbose
          new Install().run({callback, commandArgs})


      return callback(error) if error?

      if options.argv.json
        packagesWithLatestVersionOrSha = updates.map ({pack, latestVersion, sha}) ->
          pack.latestVersion = latestVersion if latestVersion
          pack.sha = sha if sha
          pack
        console.log JSON.stringify(packagesWithLatestVersionOrSha)
      else
        console.log "Package Updates Available".cyan + " (#{updates.length})"
        tree updates, ({pack, latestVersion, sha}) ->
          {name, apmInstallSource, version} = pack
          name = name.yellow
          if sha?
            version = apmInstallSource.sha.substr(0, 8).red
            latestVersion = sha.substr(0, 8).green
          else
            version = version.red
            latestVersion = latestVersion.green
          latestVersion = latestVersion?.green or apmInstallSource?.sha?.green
          "#{name} #{version} -> #{latestVersion}"

      return callback() if options.command is 'outdated'
      return callback() if options.argv.list
