Merge pull request #414 from Asp1d/master
Added support of .rubocop.yml file in project root
This commit is contained in:
commit
018f0c03ac
|
@ -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'
|
||||
|
||||
config = {
|
||||
"Style/IndentationWidth":
|
||||
"Width": options.indent_size
|
||||
}
|
||||
configStr = yaml.safeDump(config)
|
||||
@debug("rubocop", config, configStr)
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
# )
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue