2020-06-11 00:54:34 +02:00
|
|
|
import os
|
2016-08-18 13:51:25 +02:00
|
|
|
|
2023-03-31 00:31:05 +02:00
|
|
|
from scripts.lib.zulip_tools import run
|
2016-08-18 13:51:25 +02:00
|
|
|
|
2017-07-28 00:18:23 +02:00
|
|
|
DEFAULT_PRODUCTION = False
|
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
|
2023-03-20 19:52:59 +01:00
|
|
|
def setup_node_modules(production: bool = DEFAULT_PRODUCTION) -> None:
|
2021-02-12 08:20:45 +01:00
|
|
|
if os.path.islink("node_modules"):
|
2023-03-20 19:52:59 +01:00
|
|
|
os.unlink("node_modules")
|
2021-02-12 08:19:30 +01:00
|
|
|
|
2023-03-20 19:52:59 +01:00
|
|
|
try:
|
|
|
|
with open("node_modules/.pnpm/lock.yaml") as a, open("pnpm-lock.yaml") as b:
|
|
|
|
if a.read() == b.read():
|
|
|
|
return
|
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
2017-07-27 23:22:52 +02:00
|
|
|
|
2023-03-31 00:31:05 +02:00
|
|
|
run(
|
|
|
|
[
|
|
|
|
"/usr/local/bin/pnpm",
|
|
|
|
"install",
|
|
|
|
"--frozen-lockfile",
|
|
|
|
*(["--prod"] if production else []),
|
|
|
|
]
|
|
|
|
)
|