diff --git a/catfish/project/__init__.py b/catfish/project/__init__.py index aff42b5..d49d764 100644 --- a/catfish/project/__init__.py +++ b/catfish/project/__init__.py @@ -1,3 +1,4 @@ +import os import re from dataclasses import dataclass, field from pathlib import Path @@ -67,6 +68,15 @@ class Project: def get_extra_path(self): return [self.root.joinpath("node_modules/.bin"), self.root.joinpath("env/bin")] + def get_environment(self): + return { + **self.env, + "PYTHONUNBUFFERED": "1", + "PATH": "{}:{}".format( + ":".join(map(str, self.get_extra_path())), os.environ["PATH"] + ), + } + @dataclass class Process: diff --git a/catfish/worker/server.py b/catfish/worker/server.py index 7400b41..615c94f 100644 --- a/catfish/worker/server.py +++ b/catfish/worker/server.py @@ -68,15 +68,7 @@ async def run_process_command(project: Project, process: Process): *command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - env={ - **os.environ, - **project.env, - "PYTHONUNBUFFERED": "1", - "CATFISH_IDENT": process.ident, - "PATH": "{}:{}".format( - ":".join(map(str, project.get_extra_path())), os.environ["PATH"] - ), - }, + env={**os.environ, **project.get_environment(), "CATFISH_IDENT": process.ident}, cwd=project.root ) asyncio.ensure_future(publish_stdout_for(proc, process))