From 5dae2a2af500ef34876dfea09bd2d51baea4ae90 Mon Sep 17 00:00:00 2001 From: lksz Date: Fri, 19 Feb 2021 15:19:42 -0500 Subject: [PATCH] Modified Get-Path with additonal switch -Expand * Added -Expand to Get-Path * Modified Edit-TextFile to utilize new -Expand switch --- base/Edit-TextFile.ps1 | 2 +- base/Get-Path.ps1 | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/base/Edit-TextFile.ps1 b/base/Edit-TextFile.ps1 index 65da834..1d4ca76 100644 --- a/base/Edit-TextFile.ps1 +++ b/base/Edit-TextFile.ps1 @@ -23,7 +23,7 @@ if( $editor -match 'code(\.exe)?$' ) { } } -$local:arguments = $Path | Get-Path | Join-String -Separator "' '" +$local:arguments = $Path | Get-Path -Expand | Join-String -Separator "' '" if( $Path ) { $arguments = "'$arguments'" } if( $PSCmdlet.ShouldProcess( "Edit ($editor): $arguments" ) ) { diff --git a/base/Get-Path.ps1 b/base/Get-Path.ps1 index d58f521..ff35615 100644 --- a/base/Get-Path.ps1 +++ b/base/Get-Path.ps1 @@ -1,4 +1,5 @@ [CmdletBinding()]param( + [switch]$Expand, [Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName,Position=0)] [Alias("FullName")] [string[]]$Path @@ -27,10 +28,16 @@ process { } if([System.IO.Path]::IsPathRooted($p)){ - [System.IO.Path]::GetFullPath($p) + $p = [System.IO.Path]::GetFullPath($p) }else{ - [System.IO.Path]::GetFullPath((Join-Path $PWD $p)) + $p = [System.IO.Path]::GetFullPath((Join-Path $PWD $p)) } + + if( $Expand ) { + $p = $p | Get-Item | Select-Object -ExpandProperty FullName + } + + $p } } # try {