From 1598a614b248085d16006b79cd55f6fbce4d6bf5 Mon Sep 17 00:00:00 2001 From: Kirill Dubovitskiy Date: Sun, 6 Aug 2023 18:31:52 -0700 Subject: [PATCH] Fixed up broken script for installing extension built locally - we can probably just kill this code --- extension/scripts/install_from_source.py | 33 ++++++++++++------------ 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/extension/scripts/install_from_source.py b/extension/scripts/install_from_source.py index 5e16bf210..cd8f5cde7 100644 --- a/extension/scripts/install_from_source.py +++ b/extension/scripts/install_from_source.py @@ -1,3 +1,5 @@ +# Run from extension/scripts directory + import os import subprocess @@ -5,23 +7,22 @@ import subprocess def run(cmd: str): return subprocess.run(cmd, shell=True, capture_output=False) - def get_latest_version() -> str: - latest = None - latest_major = 0 - latest_minor = 0 - latest_patch = 0 - for file in os.listdir("../build"): - if file.endswith(".vsix"): - version = file.split("-")[1].split(".vsix")[0] - major, minor, patch = list( - map(lambda x: int(x), version.split("."))) - if latest is None or (major >= latest_major and minor >= latest_minor and patch > latest_patch): - latest = file - latest_major = major - latest_minor = minor - latest_patch = patch + # Ensure build directory exists + if not os.path.exists("../build"): + os.mkdir("../build") + + def version_tuple(filename): + version = filename.split("-")[1].split(".vsix")[0] + return tuple(map(int, version.split("."))) + versions = [file for file in os.listdir("../build") if file.endswith(".vsix")] + + # Ensure we have at least one version + if len(versions) == 0: + return None + + return max(versions, key=version_tuple) def main(): # Clear out old stuff @@ -62,7 +63,7 @@ def main(): latest = get_latest_version() resp = run(f"cd ..; code --install-extension ./build/{latest}") - + print("Continue VS Code extension installed successfully. Please restart VS Code to use it.")