mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Added path function to PrefixedCommandRunner
This commit is contained in:
parent
bd6e62e28d
commit
6f0d566199
4 changed files with 44 additions and 12 deletions
|
|
@ -33,10 +33,13 @@ class PrefixedCommandRunner(object):
|
|||
|
||||
return proc.returncode, stdout, stderr
|
||||
|
||||
def path(self, path_end):
|
||||
path = os.path.join(self.prefix_dir, path_end)
|
||||
return os.path.normpath(path)
|
||||
|
||||
@classmethod
|
||||
def from_command_runner(cls, command_runner, prefix_postfix):
|
||||
def from_command_runner(cls, command_runner, path_end):
|
||||
"""Constructs a new command runner from an existing one by appending
|
||||
`prefix_postfix` to the command runner's prefix directory.
|
||||
`path_end` to the command runner's prefix directory.
|
||||
"""
|
||||
new_prefix = os.path.join(command_runner.prefix_dir, prefix_postfix)
|
||||
return cls(new_prefix, popen=command_runner.__popen)
|
||||
return cls(command_runner.path(path_end), popen=command_runner.__popen)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue