From 3c624a8d4494e276460fbcaecf41e4a697e2b12a Mon Sep 17 00:00:00 2001 From: Timothy McCoy Date: Tue, 5 Aug 2014 15:10:26 -0400 Subject: [PATCH 1/2] Add extensions configuration option. Signed-off-by: Timothy McCoy --- lib/init.coffee | 1 + lib/linter-cpplint.coffee | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/init.coffee b/lib/init.coffee index 2eaee34..dd3847c 100644 --- a/lib/init.coffee +++ b/lib/init.coffee @@ -3,6 +3,7 @@ path = require 'path' module.exports = configDefaults: filters: '' + extensions: '' cpplintExecutablePath: path.join __dirname, '..', 'bin' activate: -> diff --git a/lib/linter-cpplint.coffee b/lib/linter-cpplint.coffee index b44abda..de1064b 100644 --- a/lib/linter-cpplint.coffee +++ b/lib/linter-cpplint.coffee @@ -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 From 2ef6a875b8d1800d5c7b184b2008b2f072b279c7 Mon Sep 17 00:00:00 2001 From: timikoy Date: Tue, 5 Aug 2014 17:12:14 -0400 Subject: [PATCH 2/2] Add 'c++' extension default for back compatibility --- lib/init.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/init.coffee b/lib/init.coffee index dd3847c..57eb466 100644 --- a/lib/init.coffee +++ b/lib/init.coffee @@ -3,7 +3,7 @@ path = require 'path' module.exports = configDefaults: filters: '' - extensions: '' + extensions: 'c++' cpplintExecutablePath: path.join __dirname, '..', 'bin' activate: ->