import os from pathlib import Path import subprocess import sys try: subprocess.run( ["bun", "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL ) except FileNotFoundError: print("bun not found, please run the following command to install it:") print('powershell -c "irm bun.sh/install.ps1|iex"') sys.exit(1) file_dir = Path(__file__).parent itame_vendor_dir = file_dir / "itame" if not itame_vendor_dir.exists(): print("script must be placed in the parent directory of the vendor itame directory") sys.exit(1) node_modules_dir = itame_vendor_dir / "node_modules" entrypoint = itame_vendor_dir / "index.ts" if not node_modules_dir.exists(): old_dir = os.getcwd() os.chdir(itame_vendor_dir) p = subprocess.run(["bun", "i"]) if p.returncode != 0: print("failed to install node modules") sys.exit(1) os.chdir(old_dir) subprocess.run(["bun", "run", str(entrypoint)] + sys.argv[1:])