Skip to content

Commit

Permalink
Fix package storage directory structure
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
deathaxe authored and rwols committed May 23, 2022
1 parent 5a6a555 commit b48171d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b48171d

Please sign in to comment.