Skip to content

Commit

Permalink
Merge pull request SublimeLinter#444 from trashhalo/master
Browse files Browse the repository at this point in the history
allow linters to override how chdir is computed
  • Loading branch information
groteworld committed Apr 30, 2016
2 parents 628befa + c8b1704 commit f6c5a28
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions lint/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,19 @@ def build_options(self, options, type_map, transform=None):

options[name] = value

def get_chdir(self, settings):
"""Find the chdir to use with the linter."""
chdir = settings.get('chdir', None)

if chdir and os.path.isdir(chdir):
return chdir
persist.debug('chdir has been set to: {0}'.format(chdir))
else:
if self.filename:
return os.path.dirname(self.filename)
else:
return os.path.realpath('.')

def lint(self, hit_time):
"""
Perform the lint, retrieve the results, and add marks to the view.
Expand All @@ -1370,15 +1383,7 @@ def lint(self, hit_time):
return

settings = self.get_view_settings()
self.chdir = settings.get('chdir', None)

if self.chdir and os.path.isdir(self.chdir):
persist.debug('chdir has been set to: {0}'.format(self.chdir))
else:
if self.filename:
self.chdir = os.path.dirname(self.filename)
else:
self.chdir = os.path.realpath('.')
self.chdir = self.get_chdir(settings)

with util.cd(self.chdir):
output = self.run(cmd, self.code)
Expand Down

0 comments on commit f6c5a28

Please sign in to comment.