Skip to content

Commit

Permalink
fix(ps1): copy first, then call
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlindquist committed Oct 11, 2024
1 parent 29d65d2 commit 5264f6f
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions scripts/pnpm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,38 @@ Invoke-WebRequest $archiveUrl -OutFile $tempFile -UseBasicParsing

Write-Host "Running setup...`n" -ForegroundColor Green

if ($platform -ne 'win') {
chmod +x $tempFile
}

$KIT_PNPM_HOME = Join-Path $env:USERPROFILE ".kit"
$env:KIT_PNPM_HOME = $KIT_PNPM_HOME

$targetDir = $KIT_PNPM_HOME
$newExecPath = Join-Path $targetDir (Split-Path $tempFile -Leaf)

if ((Resolve-Path $newExecPath) -ne (Resolve-Path $tempFile)) {
Write-Host "Copying pnpm CLI from $tempFile to $newExecPath"
# Create the target directory if it doesn't exist
if (-not (Test-Path $targetDir)) {
New-Item -ItemType Directory -Force -Path $targetDir | Out-Null
Write-Host "Created directory: $targetDir"
}

# Copy the file to the new location
try {
Copy-Item $tempFile $newExecPath -Force
Write-Host "Successfully copied pnpm CLI from $tempFile to $newExecPath"
} catch {
Write-Error "Failed to copy pnpm CLI: $_"
exit 1
}

# Set execute permissions on non-Windows platforms
if ($platform -ne 'win') {
try {
chmod +x $newExecPath
Write-Host "Set execute permissions for $newExecPath"
} catch {
Write-Error "Failed to set execute permissions: $_"
exit 1
}
}

Remove-Item $tempFile
Remove-Item $tempFileFolder -Recurse
# Clean up temporary files
Remove-Item $tempFile -ErrorAction SilentlyContinue
Remove-Item $tempFileFolder -Recurse -ErrorAction SilentlyContinue

0 comments on commit 5264f6f

Please sign in to comment.