diff --git a/CHANGELOG.md b/CHANGELOG.md index 62c4f9b4d0..482707213f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [Unreleased](https://github.com/ScoopInstaller/Scoop/compare/master...develop) + +### Code Refactoring + +- **relpath:** Use `$PSScriptRoot` instead of `relpath` ([#4793](https://github.com/ScoopInstaller/Scoop/issues/4793) + ## [v0.1.0](https://github.com/ScoopInstaller/Scoop/compare/2021-12-26...v0.1.0) - 2022-03-01 ### Features diff --git a/bin/refresh.ps1 b/bin/refresh.ps1 index a3492e35f7..27a7beb95b 100644 --- a/bin/refresh.ps1 +++ b/bin/refresh.ps1 @@ -1,7 +1,7 @@ # for development, update the installed scripts to match local source . "$PSScriptRoot\..\lib\core.ps1" -$src = relpath ".." +$src = "$PSScriptRoot\.." $dest = ensure (versiondir 'scoop' 'current') # make sure not running from the installed directory diff --git a/lib/commands.ps1 b/lib/commands.ps1 index 8ae0c16526..02b55ab908 100644 --- a/lib/commands.ps1 +++ b/lib/commands.ps1 @@ -1,7 +1,6 @@ function command_files { - (Get-ChildItem (relpath '..\libexec')) ` - + (Get-ChildItem "$scoopdir\shims") ` - | Where-Object { $_.name -match 'scoop-.*?\.ps1$' } + (Get-ChildItem "$PSScriptRoot\..\libexec") + (Get-ChildItem "$scoopdir\shims") | + Where-Object 'scoop-.*?\.ps1$' -Property Name -Match } function commands { @@ -13,7 +12,7 @@ function command_name($filename) { } function command_path($cmd) { - $cmd_path = relpath "..\libexec\scoop-$cmd.ps1" + $cmd_path = "$PSScriptRoot\..\libexec\scoop-$cmd.ps1" # built in commands if (!(Test-Path $cmd_path)) { diff --git a/lib/core.ps1 b/lib/core.ps1 index 83e7a28aad..1293a9d6e9 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -402,10 +402,10 @@ function url_remote_filename($url) { } function ensure($dir) { if(!(test-path $dir)) { mkdir $dir > $null }; resolve-path $dir } -function fullpath($path) { # should be ~ rooted - $executionContext.sessionState.path.getUnresolvedProviderPathFromPSPath($path) +function fullpath($path) { + # should be ~ rooted + $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($path) } -function relpath($path) { "$($myinvocation.psscriptroot)\$path" } # relative to calling script function friendly_path($path) { $h = (Get-PsProvider 'FileSystem').home; if(!$h.endswith('\')) { $h += '\' } if($h -eq '\') { return $path }