diff --git a/README.md b/README.md index a672bde..c4af92b 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,19 @@ To install via Package Control, do the following: ## Settings For general information on how SublimeLinter works with settings, please see [Settings][settings]. For information on generic linter settings, please see [Linter Settings][linter-settings]. +### Bundler +If you are using Bundler and would like to use the locked puppet-lint version, you must set `use_bundle_exec` to true: + +```json +{ + "linters": { + "puppetlint": { + "use_bundle_exec": true + } + } +} +``` + ## Contributing If you would like to contribute enhancements or fixes, please do the following: diff --git a/linter.py b/linter.py index 51fb9fa..d5acc4f 100644 --- a/linter.py +++ b/linter.py @@ -10,23 +10,38 @@ """This module exports the PuppetLint plugin class.""" -from SublimeLinter.lint import RubyLinter, util +from SublimeLinter.lint import RubyLinter class PuppetLint(RubyLinter): - """Provides an interface to puppet-lint.""" defaults = { 'selector': 'source.puppet' } - cmd = ('puppet-lint', '--log-format', '%{line}:%{column}:%{kind}:%{message}', '*') - executable = None + + cmd = ('puppet-lint', '--log-format', '%{line}:%{column}:%{kind}:%{message}') regex = ( r'^(?P\d+):(?P\d+):' r'((?Pwarning)|(?Perror)):' r'(?P.+)' ) tempfile_suffix = '-' - error_stream = util.STREAM_STDOUT - word_re = r'^(".*?"|[-\w]+)' + + def cmd(self): + """Build command, using bundle exec if the option is set.""" + + settings = self.get_view_settings() + + command = [] + + if settings.get('use_bundle_exec', False): + command.extend(['bundle', 'exec']) + + command.extend([ + 'puppet-lint', + '--log-format', + '%{line}:%{column}:%{kind}:%{message}', + ]) + + return command