Browse Source

getpunk script fix rename/move on windows

master
Julian Noble 4 days ago
parent
commit
1526eb1bcf
  1. 5
      getpunk.cmd
  2. 1
      src/scriptapps/getpunk.bash
  3. 5
      src/scriptapps/getpunk.ps1

5
getpunk.cmd

@ -920,6 +920,7 @@ $launchdir = Get-Location #store original CWD
$scriptfolder = Resolve-Path (Split-Path -Path $PSCommandPath -Parent)
$punkfolder = ""
$scriptroot = "$([System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath))"
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
if (-not (Get-Command "git" -ErrorAction SilentlyContinue)) {
Write-Host "The git command doesn't seem to be available. Will attempt to install using winget."
@ -1018,10 +1019,12 @@ if (-not(Test-Path -Path (Join-Path -Path $punkfolder -ChildPath ".git") -PathTy
git fetch origin
if (($launchdir.Path) -eq ($scriptfolder.Path)) {
if (Test-Path -Path "${scriptroot}.cmd") {
Rename-Item -Path "${scriptroot}.cmd" -NewName "${scriptroot}.cmd.lastrun" -Force
#rename-item won't allow overwriting existing target file
Move-Item -Path "${scriptroot}.cmd" -Destination "${scriptroot}.cmd.lastrun" -Force
}
}
git pull $git_upstream master
git checkout $scriptroot.cmd
git branch --set-upstream-to=origin/master master
Set-Location $launchdir #restore original CWD

1
src/scriptapps/getpunk.bash

@ -81,6 +81,7 @@ if [[ "$punkfolder" == "$scriptdir" ]]; then
fi
fi
git pull $git_upstream master
git checkout $scriptroot.cmd
git branch --set-upstream-to=origin/master master
cd $launchdir #restore original CWD

5
src/scriptapps/getpunk.ps1

@ -11,6 +11,7 @@ $launchdir = Get-Location #store original CWD
$scriptfolder = Resolve-Path (Split-Path -Path $PSCommandPath -Parent)
$punkfolder = ""
$scriptroot = "$([System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath))"
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
if (-not (Get-Command "git" -ErrorAction SilentlyContinue)) {
Write-Host "The git command doesn't seem to be available. Will attempt to install using winget."
@ -109,10 +110,12 @@ if (-not(Test-Path -Path (Join-Path -Path $punkfolder -ChildPath ".git") -PathTy
git fetch origin
if (($launchdir.Path) -eq ($scriptfolder.Path)) {
if (Test-Path -Path "${scriptroot}.cmd") {
Rename-Item -Path "${scriptroot}.cmd" -NewName "${scriptroot}.cmd.lastrun" -Force
#rename-item won't allow overwriting existing target file
Move-Item -Path "${scriptroot}.cmd" -Destination "${scriptroot}.cmd.lastrun" -Force
}
}
git pull $git_upstream master
git checkout $scriptroot.cmd
git branch --set-upstream-to=origin/master master
Set-Location $launchdir #restore original CWD

Loading…
Cancel
Save