       }
       tempConfig = @tempFile("rubocop-config", yaml.safeDump(config))
 
-    @Promise.using(@createTempFile(fullPath), (tempFileName) =>
-      new @Promise((resolve, reject) ->
-        fs.writeFile(tempFileName, text, 'utf8', (err) ->
-          return reject(err) if err?
-          resolve tempFileName
-        )
-      )
-      .then(=>
-        rubocopArguments = [
-          "--auto-correct"
-          "--force-exclusion"
-          tempFileName
-        ]
-        rubocopArguments.push("--config", tempConfig) if tempConfig?
-        @run(rubocopPath, rubocopArguments, {ignoreReturnCode: true, cwd: projectPath})
-      )
-      .then(=> @readFile(tempFileName))
+    rubocopArguments = [
+      "--auto-correct"
+      "--force-exclusion"
+      "--stdin", relativePath
+    ]
+    rubocopArguments.push("--config", tempConfig) if tempConfig?
+    @debug("rubocop arguments", rubocopArguments)
+
+    @run(rubocopPath, rubocopArguments, {
+      ignoreReturnCode: true,
+      cwd: projectPath,
+      onStdin: (stdin) -> stdin.end text
+    }).then((stdout) =>
+      @debug("rubocop output", stdout)
+      result = stdout.split("====================\n")
+      result[result.length - 1]
     )

"use strict"
Beautifier = require('./beautifier')
path = require('path')
fs = require('fs')
temp = require('temp').track()

module.exports = class Rubocop extends Beautifier
  name: "Rubocop"

      rubocop_path: true
  }

  beautify: (text, language, options) ->
    editor = atom?.workspace?.getActiveTextEditor()
    if editor?
      fullPath = editor.getPath()
      [projectPath, relativePath] = atom.project.relativizePath(fullPath)
    else
      throw new Error("No active editor found!")

