mirror of https://github.com/zulip/zulip.git
node_cache: Run pnpm install if node_modules not present in help-beta.
We need this check when switching between branches without `help-beta` package. `node_modules` will be removed when working on a non `help-beta` branch, but if `node_modules/.pnpm/lock.yaml` has not been updated by that branch, we will end up in a situation where we might not have `node_modules` even when we run the provision command. We might not need this check when the `help-beta` initial folder has been merged for a week or two, where almost all active PRs would have been rebased upon main, making switching branches an ease.
This commit is contained in:
parent
dfc426a057
commit
d7889221db
|
@ -9,20 +9,31 @@ def setup_node_modules(production: bool = DEFAULT_PRODUCTION) -> None:
|
||||||
if os.path.islink("node_modules"):
|
if os.path.islink("node_modules"):
|
||||||
os.unlink("node_modules")
|
os.unlink("node_modules")
|
||||||
|
|
||||||
|
skip = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open("node_modules/.pnpm/lock.yaml") as a, open("pnpm-lock.yaml") as b:
|
with open("node_modules/.pnpm/lock.yaml") as a, open("pnpm-lock.yaml") as b:
|
||||||
if a.read() == b.read():
|
if a.read() == b.read():
|
||||||
return
|
skip = True
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
run(
|
# We need this check when switching between branches without `help-beta`
|
||||||
[
|
# package. `node_modules` will be removed when working on a non `help-beta`
|
||||||
"/usr/local/bin/corepack",
|
# branch, but if `node_modules/.pnpm/lock.yaml` has not been updated by that
|
||||||
"pnpm",
|
# branch, we will end up in a situation where we might not have `node_modules`
|
||||||
"install",
|
# even when we run the provision command.
|
||||||
"--frozen-lockfile",
|
if not os.path.exists("help-beta/node_modules"):
|
||||||
"--prefer-offline",
|
skip = False
|
||||||
*(["--prod"] if production else []),
|
|
||||||
]
|
if not skip:
|
||||||
)
|
run(
|
||||||
|
[
|
||||||
|
"/usr/local/bin/corepack",
|
||||||
|
"pnpm",
|
||||||
|
"install",
|
||||||
|
"--frozen-lockfile",
|
||||||
|
"--prefer-offline",
|
||||||
|
*(["--prod"] if production else []),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue