From ccaaadf37146e1ff2f0330a72787f9294a9c292a Mon Sep 17 00:00:00 2001 From: lksz Date: Fri, 2 Oct 2020 15:42:40 -0400 Subject: [PATCH] Setup fixed setup of MyPSScriptRoot (again) --- Reload-MyScripts.ps1 | 5 ++++- Setup-Profile.ps1 | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Reload-MyScripts.ps1 b/Reload-MyScripts.ps1 index a68e497..2762b22 100644 --- a/Reload-MyScripts.ps1 +++ b/Reload-MyScripts.ps1 @@ -55,7 +55,10 @@ if( Get-Command Remove-Alias -ErrorAction SilentlyContinue ) { } if( $(. Get-ScopeDepth) -gt 0 ) { Write-Host -ForegroundColor Red "Try sourcing Reload-MyScripts instead of just running it" } -Get-ChildItem $(Join-Path $MyPSScriptRoot profile.d) -Filter '*.ps1' | ForEach-Object { ". '$($_.FullName)';" } | Invoke-Expression +Get-ChildItem $(Join-Path $MyPSScriptRoot profile.d) -Filter '*.ps1' | ForEach-Object { + Write-Verbose "Loading $($_.FullName -replace '\.ps1$','' -replace "^$([regex]::Escape($MyPSScriptRoot)).",'')..."; + ". '$($_.FullName)';" + } | Invoke-Expression $local:CommandsToAlias = ( @( $MyPSScriptRoot ) + $( diff --git a/Setup-Profile.ps1 b/Setup-Profile.ps1 index 46363f1..ae273b3 100644 --- a/Setup-Profile.ps1 +++ b/Setup-Profile.ps1 @@ -6,7 +6,7 @@ [switch]$NoGitClone, [string]$GitURL = 'https://code.lksz.me/lksz/PowerShell_Scripts', [Parameter(DontShow)] - [string]$MyPSScriptRoot = $MyPSScriptRoot + [string]$My_PSScriptRoot = $MyPSScriptRoot ) function _Setup { @@ -18,7 +18,7 @@ function _Setup { [switch]$NoGitClone, [string]$GitURL = 'https://code.lksz.me/lksz/PowerShell_Scripts', [Parameter(DontShow)] - [string]$MyPSScriptRoot = $MyPSScriptRoot) + [string]$My_PSScriptRoot = $MyPSScriptRoot) ####################################################################### @@ -41,6 +41,7 @@ Get-Command Reload-MyScripts -ErrorAction SilentlyContinue | ForEach-Object { . ####################################################################### . ProfileCode_common + if( -not $MyPSScriptRoot ) { throw '$MyPSScriptRoot does NOT exist!' } if ( -not $NoGitClone -and -not (Test-Path $(Join-Path $MyPSScriptRoot '.git')) ) { if ( -not [bool]$(Get-Command git -ErrorAction SilentlyContinue) ) {