Modified Get-Path with additonal switch -Expand

* Added -Expand to Get-Path
* Modified Edit-TextFile to utilize new -Expand switch
This commit is contained in:
lksz 2021-02-19 15:19:42 -05:00
parent 0e986cfaa7
commit 5dae2a2af5
2 changed files with 10 additions and 3 deletions

View File

@ -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" ) ) {

View File

@ -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 {