Merge pull request #414 from Asp1d/master

Added support of .rubocop.yml file in project root
This commit is contained in:
Glavin Wiechert 2015-06-30 09:07:02 -03:00
commit 018f0c03ac
1 changed files with 17 additions and 14 deletions

View File

@ -15,26 +15,29 @@ module.exports = class Rubocop extends Beautifier
beautify: (text, language, options) ->
# Generate config file
yaml = require("yaml-front-matter")
path = require 'path'
fs = require 'fs'
configFile = path.join(atom.project.getPaths()[0], ".rubocop.yml")
if fs.existsSync(configFile)
@debug("rubocop", config, fs.readFileSync(configFile, 'utf8'))
else
yaml = require("yaml-front-matter")
# Generate config file
config = {
"Style/IndentationWidth":
"Width": options.indent_size
}
configStr = yaml.safeDump(config)
@debug("rubocop", config, configStr)
configFile = @tempFile("rubocop-config", yaml.safeDump(config))
@debug("rubocop", config, configFile)
@run("rubocop", [
"--auto-correct"
"--config", @tempFile("rubocop-config", configStr)
"--config", configFile
tempFile = @tempFile("temp", text)
], {ignoreReturnCode: true})
.then(=>
# console.log('rubocop', arguments, tempFile)
@readFile(tempFile)
# .then((text) ->
# console.log('rubocop', text)
# return text
# )
)