got Use-UE-Workspace creating a new session to install ushell correctly
This commit is contained in:
parent
aacd09eaa9
commit
bb2ab60ac1
|
@ -1,4 +1,4 @@
|
|||
### workspace ###
|
||||
### Workspace ###
|
||||
$workspaceSettings = "$env:USERPROFILE\.pwsh_workspace_settings.txt"
|
||||
$activeWorkspace = ""
|
||||
|
||||
|
@ -212,20 +212,27 @@ function Use-Active-UE-Workspace {
|
|||
}
|
||||
}
|
||||
|
||||
# Basically like Use-Active-UE-Workspace but this function
|
||||
# does the additional work of looking up and setting the
|
||||
# active workspace based on the provided workspace name/alias
|
||||
# Creates a new powershell session then navigates to the
|
||||
# workspace path and imports the ushell module. Creating a
|
||||
# new session is needed so that when you switch UE workspaces,
|
||||
# ushell is installed with the correct context of the workspace.
|
||||
function Use-UE-Workspace {
|
||||
param([Parameter(Mandatory=$true)]
|
||||
[string]$Name)
|
||||
[string]$Name,
|
||||
[Parameter(Mandatory=$false)]
|
||||
[bool]$NewSession = $true)
|
||||
|
||||
if($NewSession) {
|
||||
New-UE-Session -Name $Name
|
||||
}
|
||||
else {
|
||||
Use-Workspace -Name $Name
|
||||
$location = Get-Location
|
||||
|
||||
$resolvedCurrentLocation = Resolve-Path $location
|
||||
$resolvedActiveWorkspace = Resolve-Path $global:activeWorkspace
|
||||
# check that we are in the expected place then proceed
|
||||
if($resolvedCurrentLocation.ProviderPath && $resolvedActiveWorkspace.ProviderPath) {
|
||||
# Check that we are in the expected place then proceed
|
||||
if($resolvedCurrentLocation.ProviderPath -eq $resolvedActiveWorkspace.ProviderPath) {
|
||||
if(Test-Active-Workspace) {
|
||||
$ushellRelativePath = "Engine\Extras\ushell\ushell.psm1"
|
||||
$ushellPath = "{0}\{1}" -f $resolvedActiveWorkspace, $ushellRelativePath
|
||||
|
@ -241,4 +248,18 @@ function Use-UE-Workspace {
|
|||
else {
|
||||
Write-Error "Did not correctly switch to workspace $Name"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function New-UE-Session {
|
||||
param([Parameter(Mandatory=$true)]
|
||||
[string]$Name)
|
||||
if(Test-Workspace-Alias -Alias $Name) {
|
||||
Start-Process pwsh -ArgumentList @("-NoExit", "-Command", "& {. $PROFILE; Use-UE-Workspace -Name $Name -NewSession `$false`}")
|
||||
Stop-Process -Id $PID
|
||||
}
|
||||
else {
|
||||
Write-Host "Alias $Name does not exist, not creating new session"
|
||||
}
|
||||
}
|
||||
### Workspace ###
|
||||
|
|
Loading…
Reference in New Issue
Block a user