Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(relpath): Use $PSScriptRoot instead of relpath #4793

Merged
merged 2 commits into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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