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) ->
|
beautify: (text, language, options) ->
|
||||||
|
|
||||||
# Generate config file
|
path = require 'path'
|
||||||
yaml = require("yaml-front-matter")
|
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 = {
|
config = {
|
||||||
"Style/IndentationWidth":
|
"Style/IndentationWidth":
|
||||||
"Width": options.indent_size
|
"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", [
|
@run("rubocop", [
|
||||||
"--auto-correct"
|
"--auto-correct"
|
||||||
"--config", @tempFile("rubocop-config", configStr)
|
"--config", configFile
|
||||||
tempFile = @tempFile("temp", text)
|
tempFile = @tempFile("temp", text)
|
||||||
], {ignoreReturnCode: true})
|
], {ignoreReturnCode: true})
|
||||||
.then(=>
|
.then(=>
|
||||||
# console.log('rubocop', arguments, tempFile)
|
|
||||||
@readFile(tempFile)
|
@readFile(tempFile)
|
||||||
# .then((text) ->
|
|
||||||
# console.log('rubocop', text)
|
|
||||||
# return text
|
|
||||||
# )
|
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue