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

Add extensions configuration option. #4

Merged
merged 2 commits into from
Aug 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/init.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ path = require 'path'
module.exports =
configDefaults:
filters: ''
extensions: 'c++'
cpplintExecutablePath: path.join __dirname, '..', 'bin'

activate: ->
Expand Down
21 changes: 16 additions & 5 deletions lib/linter-cpplint.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,25 @@ class LinterCpplint extends Linter
@executablePath = atom.config.get 'linter-cpplint.cpplintExecutablePath'

atom.config.observe 'linter-cpplint.filters', =>
filters = atom.config.get 'linter-cpplint.filters'
if filters.length == 0
@cmd = 'cpplint.py --extensions=c++'
else
@cmd = 'cpplint.py --extensions=c++ --filter=' + filters
@updateCommand()

atom.config.observe 'linter-cpplint.extensions', =>
@updateCommand()

updateCommand: ->
filters = atom.config.get 'linter-cpplint.filters'
extensions = atom.config.get 'linter-cpplint.extensions'
cmd = "cpplint.py"
if filters
cmd = "#{cmd} --filter=#{filters}"
if extensions
cmd = "#{cmd} --extensions=#{extensions}"
@cmd = cmd


destroy: ->
atom.config.unobserve 'linter-cpplint.filters'
atom.config.unobserve 'linter-cpplint.extensions'
atom.config.unobserve 'linter-cpplint.cpplintExecutablePath'

# Private: cpplint outputs line 0 for some errors. This needs to be changed to
Expand Down