From b48171d3f67dbf3eb56a50f9a065e7f6f07beaba Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Mon, 23 May 2022 16:31:16 +0200 Subject: [PATCH] Fix package storage directory structure This commit... 1. installs the language server and all its dependencies into LSP-PowerShellEditorServices directory 2. fixes an issue with `dll_path()` which causes the language-server to be re-installed each time it is instantiated. 3. Both `start_script()` and `dll_path()` now use fixed "PowerShellEditorServices" instead of `cls.name()` because it is a fixed folder name, which doesn't need to be related with the display name of the service. --- plugin.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/plugin.py b/plugin.py index 6079459..812834b 100644 --- a/plugin.py +++ b/plugin.py @@ -77,7 +77,7 @@ def basedir(cls) -> str: @classmethod def start_script(cls) -> str: - return os.path.join(cls.basedir(), "Start-EditorServices.ps1") + return os.path.join(cls.basedir(), "PowerShellEditorServices", "Start-EditorServices.ps1") @classmethod def host_version(cls) -> str: @@ -97,7 +97,13 @@ def bundled_modules_path(cls) -> str: @classmethod def dll_path(cls) -> str: - return os.path.join(cls.basedir(), cls.name(), "bin", "Common", "Microsoft.PowerShell.EditorServices.dll") + return os.path.join( + cls.basedir(), + "PowerShellEditorServices", + "bin", + "Common", + "Microsoft.PowerShell.EditorServices.dll" + ) @classmethod def version_str(cls) -> str: @@ -145,8 +151,7 @@ def install_or_update(cls) -> None: zipfile = os.path.join(cls.storage_path(), "{}.zip".format(cls.name())) urlretrieve(URL.format(cls.version_str()), zipfile) with ZipFile(zipfile, "r") as f: - f.extractall(cls.storage_path()) - os.rename(os.path.join(cls.storage_path(), cls.name()), cls.basedir()) + f.extractall(cls.basedir()) os.unlink(zipfile) except Exception: shutil.rmtree(cls.basedir(), ignore_errors=True)