Skip to content

Prepend the installed tool path in the env/sys path #45

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

Merged
merged 2 commits into from
Feb 4, 2025
Merged
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
12 changes: 6 additions & 6 deletions containers-toolkit/Private/CommonToolUtilities.psm1
Original file line number Diff line number Diff line change
@@ -252,10 +252,10 @@ function Get-InstallationFile {
}

# Verify that both the archive and checksum files were downloaded
if (-not (Test-Path $archiveFile -ErrorAction SilentlyContinue)) {
if (-not (Test-Path $archiveFile)) {
Throw "Archive file not found in the release assets: `'$archiveFile`""
}
if (-not (Test-Path $checksumFile -ErrorAction SilentlyContinue)) {
if (-not (Test-Path $checksumFile)) {
Throw "Checksum file not found in the release assets: `'$checksumFile`""
}

@@ -274,15 +274,15 @@ function Get-InstallationFile {
}

# Remove the checksum file after verification
if (Test-Path -Path $checksumFile -ErrorAction SilentlyContinue) {
if (Test-Path -Path $checksumFile) {
Remove-Item -Path $checksumFile -Force -ErrorAction SilentlyContinue
}

if (-not $isValidChecksum) {
Write-Error "Checksum verification failed for $archiveFile. The file will be deleted."

# Remove the checksum file after verification
if (Test-Path -Path $archiveFile -ErrorAction SilentlyContinue) {
if (Test-Path -Path $archiveFile) {
Remove-Item -Path $archiveFile -Force -ErrorAction SilentlyContinue
}
Throw "Checksum verification failed. One or more files are corrupted."
@@ -428,11 +428,11 @@ function Test-CheckSum {

Write-Debug "Checksum verification...`n`tSource file: $DownloadedFile`n`tChecksum file: $ChecksumFile"

if (-not (Test-Path -Path $downloadedFile -ErrorAction Continue)) {
if (-not (Test-Path -Path $downloadedFile)) {
Throw "Couldn't find source file: `"$downloadedFile`"."
}

if (-not (Test-Path -Path $ChecksumFile -ErrorAction Continue)) {
if (-not (Test-Path -Path $ChecksumFile)) {
Throw "Couldn't find checksum file: `"$ChecksumFile`"."
}

9 changes: 5 additions & 4 deletions containers-toolkit/Private/UpdateEnvironmentPath.psm1
Original file line number Diff line number Diff line change
@@ -41,14 +41,15 @@ function Update-EnvironmentPath {
}

# Check if the path needs to be changed
$pathFound = "$Path" -in ($parsedPathString -split ";")
switch ($Action) {
"Add" {
$pathChanged = $parsedPathString -notlike "*$Tool*"
$pathChanged = (-not $pathFound)
$toAction = $Path
$ActionVerb = "Adding"
}
"Remove" {
$pathChanged = $parsedPathString -like "*$Tool*"
$pathChanged = $pathFound
$toAction = $Tool
$ActionVerb = "Removing"
}
@@ -109,11 +110,11 @@ function AddFeatureToPath ($PathString, $ToolPath) {
if (!$PathString) {
Throw 'Env path cannot be null or an empty string'
}
return "$PathString;$ToolPath"
return (ParsePathString -PathString "$ToolPath;$PathString")
}

function RemoveFeatureFromPath ($PathString, $Tool) {
$pathString = ParsePathString -Path $pathString
$pathString = ParsePathString -PathString $pathString
$parsedString = $pathString -split ";" | Where-Object { ($_ -notlike "*$tool*") }

if (!$parsedString) {
Loading
Oops, something went wrong.