       actom.activatePackage(name) if activateOnFailure
       callback(new Error("Installing '#{name}' failed."))
 
+  new BufferedProcess({command, args, exit})
+
 uninstall = ({name}, callback) ->
   atom.deactivatePackage(name) if atom.isPackageActive(name)
 
-  apm = require.resolve '.bin/apm'
-  apmProcess = spawn(apm, ['uninstall', name])
-  apmProcess.on 'close', (code) =>
+  command = require.resolve '.bin/apm'
+  args = ['uninstall', name]
+  exit = (code) ->
     if code is 0
       atom.unloadPackage(name) if atom.isPackageLoaded(name)
       callback()
     else
       callback(new Error("Uninstalling '#{name}' failed."))
 
+  new BufferedProcess({command, args, exit})
+
 module.exports = {renderMarkdownInMetadata, install, uninstall, getAvailable}

  queue.drain = callback

getAvailable = (callback) ->
  apm = require.resolve '.bin/apm'
  apmProcess = spawn(apm, ['available', '--json'])
  chunks = []
  apmProcess.stdout.on 'data', (chunk) -> chunks.push(chunk)
  apmProcess.on 'close', (code) ->
    if code is 0
      try
        packages = JSON.parse(Buffer.concat(chunks).toString()) ? []
      catch error
        callback(error)
        return

BufferedProcess = require 'buffered-process'
roaster = require 'roaster'
async = require 'async'

