Skip to content

Commit 1985a05

Browse files
authored
refactor(path): Use 'Convert-Path()' instead of 'Resolve-Path()' (#5109)
1 parent dea9ebb commit 1985a05

14 files changed

Lines changed: 20 additions & 16 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

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

14+
### Code Refactoring
15+
16+
- **path:** Use 'Convert-Path()' instead of 'Resolve-Path()' ([#5109](https://github.com/ScoopInstaller/Scoop/issues/5109))
17+
1418
### Builds
1519

1620
- **schema**: Set manifest schema to be stricter ([#5093](https://github.com/ScoopInstaller/Scoop/issues/5093))

bin/auto-pr.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ param(
6666
if ($App -ne '*' -and (Test-Path $App -PathType Leaf)) {
6767
$Dir = Split-Path $App
6868
} elseif ($Dir) {
69-
$Dir = Resolve-Path $Dir
69+
$Dir = Convert-Path $Dir
7070
} else {
7171
throw "'-Dir' parameter required if '-App' is not a filepath!"
7272
}

bin/checkhashes.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ param(
4949
. "$PSScriptRoot\..\lib\install.ps1"
5050
. "$PSScriptRoot\..\lib\unix.ps1"
5151

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

176176
$current.manifest = $current.manifest | ConvertToPrettyJson
177-
$path = Resolve-Path "$Dir\$($current.app).json"
177+
$path = Convert-Path "$Dir\$($current.app).json"
178178
[System.IO.File]::WriteAllLines($path, $current.manifest)
179179
}
180180
}

bin/checkurls.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ param(
3030
. "$PSScriptRoot\..\lib\manifest.ps1"
3131
. "$PSScriptRoot\..\lib\install.ps1"
3232

33-
$Dir = Resolve-Path $Dir
33+
$Dir = Convert-Path $Dir
3434
$Queue = @()
3535

3636
Get-ChildItem $Dir "$App.json" | ForEach-Object {

bin/checkver.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ if ($App -ne '*' -and (Test-Path $App -PathType Leaf)) {
8080
$Dir = Split-Path $App
8181
$files = Get-ChildItem $Dir (Split-Path $App -Leaf)
8282
} elseif ($Dir) {
83-
$Dir = Resolve-Path $Dir
83+
$Dir = Convert-Path $Dir
8484
$files = Get-ChildItem $Dir "$App.json"
8585
} else {
8686
throw "'-Dir' parameter required if '-App' is not a filepath!"

bin/describe.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ param(
2424
. "$PSScriptRoot\..\lib\manifest.ps1"
2525
. "$PSScriptRoot\..\lib\description.ps1"
2626

27-
$Dir = Resolve-Path $Dir
27+
$Dir = Convert-Path $Dir
2828
$Queue = @()
2929

3030
Get-ChildItem $Dir "$App.json" | ForEach-Object {

bin/formatjson.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ param(
3131
. "$PSScriptRoot\..\lib\manifest.ps1"
3232
. "$PSScriptRoot\..\lib\json.ps1"
3333

34-
$Dir = Resolve-Path $Dir
34+
$Dir = Convert-Path $Dir
3535

3636
Get-ChildItem $Dir "$App.json" | ForEach-Object {
3737
if ($PSVersionTable.PSVersion.Major -gt 5) { $_ = $_.Name } # Fix for pwsh

bin/missing-checkver.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ param(
2626
. "$PSScriptRoot\..\lib\core.ps1"
2727
. "$PSScriptRoot\..\lib\manifest.ps1"
2828

29-
$Dir = Resolve-Path $Dir
29+
$Dir = Convert-Path $Dir
3030

3131
Write-Host '[' -NoNewLine
3232
Write-Host 'C' -NoNewLine -ForegroundColor Green

lib/core.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ function shim($path, $global, $name, $arg) {
717717
Push-Location $abs_shimdir
718718
$relative_path = Resolve-Path -Relative $path
719719
Pop-Location
720-
$resolved_path = Resolve-Path $path
720+
$resolved_path = Convert-Path $path
721721

722722
if ($path -match '\.(exe|com)$') {
723723
# for programs with no awareness of any shell

lib/manifest.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ function generate_user_manifest($app, $bucket, $version) {
147147

148148
ensure $(usermanifestsdir) | out-null
149149
try {
150-
Invoke-AutoUpdate $app "$(resolve-path $(usermanifestsdir))" $manifest $version $(@{ })
151-
return "$(resolve-path $(usermanifest $app))"
150+
Invoke-AutoUpdate $app "$(Convert-Path (usermanifestsdir))" $manifest $version $(@{ })
151+
return "$(Convert-Path (usermanifest $app))"
152152
} catch {
153153
write-host -f darkred "Could not install $app@$version"
154154
}

0 commit comments

Comments
 (0)