Skip to content

Commit

Permalink
webapp: autocompile script needs to run yarn within webapp dir
Browse files Browse the repository at this point in the history
we need to change the working directory to the webapp directory such
that corepack installs and uses the expected version of yarn. otherwise,
corepack installs a copy of yarn into the repository root directory.
  • Loading branch information
schlimmchen committed Sep 21, 2024
1 parent a2092e6 commit 2f4eef4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pio-scripts/compile_webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,25 @@ def check_files(directories, filepaths, hash_file):
# "exectuable" (a shell script) is only performed by cmd.exe, not by
# Python itself. as we are calling yarn with fixed arguments, using
# shell=True is fine.
# we need to change the working directory to the webapp directory such
# that corepack installs and uses the expected version of yarn. otherwise,
# corepack installs a copy of yarn into the repository root directory.
yarn = "yarn"
try:
subprocess.check_output(yarn + " --version", shell=True)
subprocess.check_output(yarn + " --version", cwd="webapp", shell=True)
except FileNotFoundError:
yarn = "yarnpkg"
try:
subprocess.check_output(yarn + " --version", shell=True)
subprocess.check_output(yarn + " --version", cwd="webapp", shell=True)
except FileNotFoundError:
raise Exception("it seems neither 'yarn' nor 'yarnpkg' is available on your system")

# if these commands fail, an exception will prevent us from
# persisting the current hashes => commands will be executed again
subprocess.run(yarn + " --cwd webapp install --frozen-lockfile",
check=True, shell=True)
subprocess.run(yarn + " install --frozen-lockfile",
cwd="webapp", check=True, shell=True)

subprocess.run(yarn + " --cwd webapp build", check=True, shell=True)
subprocess.run(yarn + " build", cwd="webapp", check=True, shell=True)

with open(hash_file, 'wb') as f:
pickle.dump(file_hashes, f)
Expand Down

0 comments on commit 2f4eef4

Please sign in to comment.