Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #30 from rfocosi/search-rubocop-config
Browse files Browse the repository at this point in the history
Searching for project's `.rubocop.yml` on project root folder
  • Loading branch information
tomoya authored Jul 20, 2016
2 parents a21833b + 963c4d2 commit cdcb30d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/rubocop-auto-correct.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,21 @@ class RubocopAutoCorrect
else
@autoCorrectBuffer(editor.getBuffer())

projectRootRubocopConfig: (filePath) ->
[projectPath, relativePath] = atom.project.relativizePath(filePath)
rubocopConfigPath = projectPath+'/.rubocop.yml'
if (fs.existsSync(rubocopConfigPath))
['--config', rubocopConfigPath]
else
[]

autoCorrectBuffer: (buffer) ->
tempFilePath = @makeTempFile("rubocop.rb")
fs.writeFileSync(tempFilePath, buffer.getText())
commandWithArgs = atom.config.get('rubocop-auto-correct.rubocopCommandPath')
.split(/\s+/).filter((i) -> i)
.concat(['-a', tempFilePath])
.concat(@projectRootRubocopConfig(buffer.getPath()))
command = commandWithArgs[0]
args = commandWithArgs[1..]
options = { encoding: 'utf-8', timeout: 5000 }
Expand Down Expand Up @@ -123,6 +132,7 @@ class RubocopAutoCorrect
commandWithArgs = atom.config.get('rubocop-auto-correct.rubocopCommandPath')
.split(/\s+/).filter((i) -> i)
.concat(['-a', filePath])
.concat(@projectRootRubocopConfig(filePath))
command = commandWithArgs[0]
args = commandWithArgs[1..]
debug = atom.config.get('rubocop-auto-correct.debugMode')
Expand Down

0 comments on commit cdcb30d

Please sign in to comment.