From a2092e66c435d1efc3be30d7e45978737df9b8b3 Mon Sep 17 00:00:00 2001 From: Bernhard Kirchen Date: Sat, 21 Sep 2024 21:00:48 +0200 Subject: [PATCH] webapp: autocompile script: use portable subprocess we added shell=True so that on Windows, yarn would be found. however, using the list syntax to define the command and its arguments to Python's subprocess is broken on GNU/Linux by shell=True. instead, use a single string (command and arguments), which works on both Windows and GNU/Linux. --- pio-scripts/compile_webapp.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pio-scripts/compile_webapp.py b/pio-scripts/compile_webapp.py index c283c1ff..4afa996a 100644 --- a/pio-scripts/compile_webapp.py +++ b/pio-scripts/compile_webapp.py @@ -39,20 +39,20 @@ def check_files(directories, filepaths, hash_file): # shell=True is fine. yarn = "yarn" try: - subprocess.check_output([yarn, "--version"], shell=True) + subprocess.check_output(yarn + " --version", shell=True) except FileNotFoundError: yarn = "yarnpkg" try: - subprocess.check_output([yarn, "--version"], shell=True) + subprocess.check_output(yarn + " --version", shell=True) except FileNotFoundError: - raise Exception("it seems neither 'yarn' nor 'yarnpkg' is installed/available on your system") + 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"], + subprocess.run(yarn + " --cwd webapp install --frozen-lockfile", check=True, shell=True) - subprocess.run([yarn, "--cwd", "webapp", "build"], check=True, shell=True) + subprocess.run(yarn + " --cwd webapp build", check=True, shell=True) with open(hash_file, 'wb') as f: pickle.dump(file_hashes, f)