-
Notifications
You must be signed in to change notification settings - Fork 3k
/
pre_build.py
27 lines (23 loc) · 954 Bytes
/
pre_build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
import subprocess
from shutil import which
from sys import exit
def main() -> None:
if os.environ.get("SKIP_PRE_BUILD", "") == "true":
print("Skipping front end build...")
return
if which("yarn") is None:
print(
"Locust requires the yarn binary to be available in this shell to build the web front-end.\nSee: https://docs.locust.io/en/stable/developing-locust.html#making-changes-to-locust-s-web-ui"
)
exit(1)
print("Building front end...")
try:
subprocess.check_output(" ".join(["yarn", "webui:install"]), shell=True)
subprocess.check_output(" ".join(["yarn", "webui:build"]), shell=True)
except subprocess.CalledProcessError as e:
raise AssertionError(f"Building front end with yarn failed with:\n\n{e.stdout}") from e
except Exception as e:
print(f"Error encountered during pre-build: {e}")
if __name__ == "__main__":
main()