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 import re
from dataclasses import dataclass, field from dataclasses import dataclass, field
from pathlib import Path from pathlib import Path
@ -67,6 +68,15 @@ class Project:
def get_extra_path(self): def get_extra_path(self):
return [self.root.joinpath("node_modules/.bin"), self.root.joinpath("env/bin")] 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 @dataclass
class Process: class Process:

View file

@ -68,15 +68,7 @@ async def run_process_command(project: Project, process: Process):
*command, *command,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
env={ env={**os.environ, **project.get_environment(), "CATFISH_IDENT": process.ident},
**os.environ,
**project.env,
"PYTHONUNBUFFERED": "1",
"CATFISH_IDENT": process.ident,
"PATH": "{}:{}".format(
":".join(map(str, project.get_extra_path())), os.environ["PATH"]
),
},
cwd=project.root cwd=project.root
) )
asyncio.ensure_future(publish_stdout_for(proc, process)) asyncio.ensure_future(publish_stdout_for(proc, process))