Move environment definition onto Project

This commit is contained in:
Jake Howard 2018-12-18 21:45:42 +00:00
parent ae5b3eeefb
commit f6c8d5b19d
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 11 additions and 9 deletions

View file

@ -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:

View file

@ -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))