         else
           deferred.resolve()
         return deferred.promise
-      saveCurrentDependencyToJson cacheName, version
+      saveCurrentDependencyToJson name, version
     else
       saveBowerJson()
 

      deferred.reject()
    .on 'end', (r) ->
      offline = false
      for e of r
        if e.pkgMeta.version is version
          offline = true
          break
      deferred.resolve [name, version, cacheName, offline]
    deferred.promise

  install = (data) ->
    isSerialInstall = data isnt undefined
    deferred = Q.defer()

    if isSerialInstall
      name = data.shift()
      version = data.shift()
      cacheName = data.shift()
      offline = data.shift()
      installedVersion = getInstalledVersion name
      if installedVersion isnt ''
        # already installed

  log = new Logger logLevel, 'Bower'

  bowerInstallDependency = (item, cb) ->
    Q.fcall checkCache, item
    .then install
    .catch (error) ->
      log.e "Install failed: #{item.name}: #{if error.stack then error.stack else error}" if error
      common.setExitCode 1
    .done ->
      if !common.hasError() and !fs.existsSync "bower_components/#{item.name}"
        log.e "Install failed: module does not exist: #{item.name}"
        common.setExitCode 1
      cb?()

