Skip to content

Commit

Permalink
Refactor "dist" constant in setup.py to class var
Browse files Browse the repository at this point in the history
  • Loading branch information
thegamecracks committed Jul 18, 2023
1 parent d4999cf commit 5765f29
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class build_npm(Command, SubCommand):
yarn_projects: list[str]
"""A list of project paths to be built with `yarn build` and installed."""

yarn_dist_dir = "dist"
"""The distribution directory that all yarn projects output to."""

# SubCommand protocol

def initialize_options(self) -> None:
Expand Down Expand Up @@ -60,7 +63,7 @@ def run(self) -> None:
for output_path in output_dir.iterdir():
if not output_path.is_dir():
output_path.unlink()
elif output_path.name != "dist":
elif output_path.name != self.yarn_dist_dir:
shutil.rmtree(output_path)

def get_source_files(self) -> list[str]:
Expand Down Expand Up @@ -89,7 +92,7 @@ def get_outputs(self) -> list[str]:
"""
files = []
for path_str in self.yarn_projects:
output_path = self._get_output_path(path_str) / "dist"
output_path = self._get_output_path(path_str) / self.yarn_dist_dir
assert output_path.is_dir(), f"failed to build {path_str}"

for file in output_path.rglob("*"):
Expand Down

0 comments on commit 5765f29

Please sign in to comment.