From 789a07e288aa23717452c7849c341b00a3d293eb Mon Sep 17 00:00:00 2001 From: Bernhard Kirchen Date: Fri, 20 Sep 2024 15:53:05 +0200 Subject: [PATCH] webapp: use shell=True in autocompile script we need shell=True as on Windows, path resolution to find the yarn "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. --- pio-scripts/compile_webapp.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pio-scripts/compile_webapp.py b/pio-scripts/compile_webapp.py index 0ae54e769..c283c1ff1 100644 --- a/pio-scripts/compile_webapp.py +++ b/pio-scripts/compile_webapp.py @@ -33,22 +33,26 @@ def check_files(directories, filepaths, hash_file): print("INFO: compiling webapp (hang on, this can take a while and there might be little output)...") + # we need shell=True as on Windows, path resolution to find the yarn + # "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. yarn = "yarn" try: - subprocess.check_output([yarn, "--version"]) + subprocess.check_output([yarn, "--version"], shell=True) except FileNotFoundError: yarn = "yarnpkg" try: - subprocess.check_output([yarn, "--version"]) + subprocess.check_output([yarn, "--version"], shell=True) except FileNotFoundError: raise Exception("it seems neither 'yarn' nor 'yarnpkg' is installed/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) + check=True, shell=True) - subprocess.run([yarn, "--cwd", "webapp", "build"], check=True) + subprocess.run([yarn, "--cwd", "webapp", "build"], check=True, shell=True) with open(hash_file, 'wb') as f: pickle.dump(file_hashes, f)