Skip to content

Commit

Permalink
refactor(relpath): Use $PSScriptRoot instead of relpath (#4793)
Browse files Browse the repository at this point in the history
  • Loading branch information
niheaven authored Mar 9, 2022
1 parent 7d5a47c commit af26d86
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion bin/refresh.ps1
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 3 additions & 4 deletions lib/commands.ps1
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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)) {
Expand Down
6 changes: 3 additions & 3 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit af26d86

Please sign in to comment.