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(path): Use 'Convert-Path()' instead of 'Resolve-Path()' #5109

Merged
merged 3 commits into from
Aug 22, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

- **config:** Change config option to snake_case in file and SCREAMING_CASE in code ([#5116](https://github.com/ScoopInstaller/Scoop/issues/5116))

### Code Refactoring

- **path:** Use 'Convert-Path()' instead of 'Resolve-Path()' ([#5109](https://github.com/ScoopInstaller/Scoop/issues/5109))

### Builds

- **schema**: Set manifest schema to be stricter ([#5093](https://github.com/ScoopInstaller/Scoop/issues/5093))
Expand Down
2 changes: 1 addition & 1 deletion bin/auto-pr.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ param(
if ($App -ne '*' -and (Test-Path $App -PathType Leaf)) {
$Dir = Split-Path $App
} elseif ($Dir) {
$Dir = Resolve-Path $Dir
$Dir = Convert-Path $Dir
} else {
throw "'-Dir' parameter required if '-App' is not a filepath!"
}
Expand Down
4 changes: 2 additions & 2 deletions bin/checkhashes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ param(
. "$PSScriptRoot\..\lib\install.ps1"
. "$PSScriptRoot\..\lib\unix.ps1"

$Dir = Resolve-Path $Dir
$Dir = Convert-Path $Dir
if ($ForceUpdate) { $Update = $true }
# Cleanup
if (!$UseCache) { Remove-Item "$cachedir\*HASH_CHECK*" -Force }
Expand Down Expand Up @@ -174,7 +174,7 @@ foreach ($current in $MANIFESTS) {
Write-Host "Writing updated $($current.app) manifest" -ForegroundColor DarkGreen

$current.manifest = $current.manifest | ConvertToPrettyJson
$path = Resolve-Path "$Dir\$($current.app).json"
$path = Convert-Path "$Dir\$($current.app).json"
[System.IO.File]::WriteAllLines($path, $current.manifest)
}
}
2 changes: 1 addition & 1 deletion bin/checkurls.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ param(
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\install.ps1"

$Dir = Resolve-Path $Dir
$Dir = Convert-Path $Dir
$Queue = @()

Get-ChildItem $Dir "$App.json" | ForEach-Object {
Expand Down
2 changes: 1 addition & 1 deletion bin/checkver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ if ($App -ne '*' -and (Test-Path $App -PathType Leaf)) {
$Dir = Split-Path $App
$files = Get-ChildItem $Dir (Split-Path $App -Leaf)
} elseif ($Dir) {
$Dir = Resolve-Path $Dir
$Dir = Convert-Path $Dir
$files = Get-ChildItem $Dir "$App.json"
} else {
throw "'-Dir' parameter required if '-App' is not a filepath!"
Expand Down
2 changes: 1 addition & 1 deletion bin/describe.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ param(
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\description.ps1"

$Dir = Resolve-Path $Dir
$Dir = Convert-Path $Dir
$Queue = @()

Get-ChildItem $Dir "$App.json" | ForEach-Object {
Expand Down
2 changes: 1 addition & 1 deletion bin/formatjson.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ param(
. "$PSScriptRoot\..\lib\manifest.ps1"
. "$PSScriptRoot\..\lib\json.ps1"

$Dir = Resolve-Path $Dir
$Dir = Convert-Path $Dir

Get-ChildItem $Dir "$App.json" | ForEach-Object {
if ($PSVersionTable.PSVersion.Major -gt 5) { $_ = $_.Name } # Fix for pwsh
Expand Down
2 changes: 1 addition & 1 deletion bin/missing-checkver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ param(
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\manifest.ps1"

$Dir = Resolve-Path $Dir
$Dir = Convert-Path $Dir

Write-Host '[' -NoNewLine
Write-Host 'C' -NoNewLine -ForegroundColor Green
Expand Down
2 changes: 1 addition & 1 deletion lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ function shim($path, $global, $name, $arg) {
Push-Location $abs_shimdir
$relative_path = Resolve-Path -Relative $path
Pop-Location
$resolved_path = Resolve-Path $path
$resolved_path = Convert-Path $path

if ($path -match '\.(exe|com)$') {
# for programs with no awareness of any shell
Expand Down
4 changes: 2 additions & 2 deletions lib/manifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ function generate_user_manifest($app, $bucket, $version) {

ensure $(usermanifestsdir) | out-null
try {
Invoke-AutoUpdate $app "$(resolve-path $(usermanifestsdir))" $manifest $version $(@{ })
return "$(resolve-path $(usermanifest $app))"
Invoke-AutoUpdate $app "$(Convert-Path (usermanifestsdir))" $manifest $version $(@{ })
return "$(Convert-Path (usermanifest $app))"
} catch {
write-host -f darkred "Could not install $app@$version"
}
Expand Down
2 changes: 1 addition & 1 deletion lib/psmodules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function uninstall_psmodule($manifest, $dir, $global) {
$linkfrom = "$modulesdir\$module_name"
if (Test-Path $linkfrom) {
Write-Host "Removing $(friendly_path $linkfrom)"
$linkfrom = Resolve-Path $linkfrom
$linkfrom = Convert-Path $linkfrom
Remove-Item -Path $linkfrom -Force -ErrorAction SilentlyContinue
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/unix.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $cachedir = $env:SCOOP_CACHE, (get_config 'CACHE_PATH'), (Join-Path $scoopdir 'c
# core.ps1
function ensure($dir) {
mkdir -p $dir > $null
return resolve-path $dir
return Convert-Path $dir
}

# install.ps1
Expand Down
2 changes: 1 addition & 1 deletion libexec/scoop-reset.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ $apps | ForEach-Object {

write-host "Resetting $app ($version)."

$dir = resolve-path (versiondir $app $version $global)
$dir = Convert-Path (versiondir $app $version $global)
$original_dir = $dir
$persist_dir = persistdir $app $global

Expand Down
4 changes: 2 additions & 2 deletions test/bin/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#Requires -Modules @{ ModuleName = 'Pester'; MaximumVersion = '4.99' }
#Requires -Modules @{ ModuleName = 'PSScriptAnalyzer'; ModuleVersion = '1.17.1' }
param(
[String] $TestPath = $(Resolve-Path "$PSScriptRoot\..\")
[String] $TestPath = $(Convert-Path "$PSScriptRoot\..\")
)

$splat = @{
Expand All @@ -21,7 +21,7 @@ if ($env:CI -eq $true) {
$commitMessage = $env:BHCommitMessage

# Check if tests are called from the Core itself, if so, adding excludes
if ($TestPath -eq $(Resolve-Path "$PSScriptRoot\..\")) {
if ($TestPath -eq $(Convert-Path "$PSScriptRoot\..\")) {
if ($commitMessage -match '!linter') {
Write-Warning "Skipping code linting per commit flag '!linter'"
$excludes += 'Linter'
Expand Down