Fix launcher paths and remove local hardcoding
This commit is contained in:
1 parent
e7a7d3f888
commit
13b1f2150c
15 files changed
+145
-66
No files matched your search
@@ -1,11 +1,17 @@
|
||||
@echo off
|
||||
REM Git自动提交和推送批处理脚本
|
||||
REM 每小时自动保存修改、提交并推送到GitHub
|
||||
REM Git auto commit and push batch launcher.
|
||||
REM Runs the PowerShell script from this scripts directory.
|
||||
|
||||
cd /d "C:\Users\12742\Desktop\douyin_guaji-main"
|
||||
cd /d "%~dp0.."
|
||||
if errorlevel 1 (
|
||||
echo Failed to switch to project root.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 运行PowerShell脚本
|
||||
powershell.exe -ExecutionPolicy Bypass -File "%~dp0auto_commit_push.ps1"
|
||||
REM Run the PowerShell script.
|
||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0auto_commit_push.ps1"
|
||||
set "EXIT_CODE=%ERRORLEVEL%"
|
||||
|
||||
pause
|
||||
|
||||
exit /b %EXIT_CODE%
|
||||
@@ -4,10 +4,39 @@
|
||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# Switch to project directory
|
||||
$projectPath = "C:\Users\12742\Desktop\douyin_guaji-main"
|
||||
# Switch to project directory (parent of this scripts directory)
|
||||
$projectPath = Resolve-Path (Join-Path $PSScriptRoot "..")
|
||||
Set-Location $projectPath
|
||||
|
||||
function Ensure-GitOnPath {
|
||||
if (Get-Command git -ErrorAction SilentlyContinue) {
|
||||
return
|
||||
}
|
||||
|
||||
$candidateDirs = @(
|
||||
"C:\Program Files\Git\cmd",
|
||||
"C:\Program Files\Git\bin",
|
||||
"C:\Program Files (x86)\Git\cmd",
|
||||
"C:\Program Files (x86)\Git\bin",
|
||||
(Join-Path $env:LOCALAPPDATA "Programs\Git\cmd"),
|
||||
(Join-Path $env:LOCALAPPDATA "Programs\Git\bin"),
|
||||
"C:\ProgramData\chocolatey\bin"
|
||||
)
|
||||
|
||||
foreach ($dir in $candidateDirs) {
|
||||
if ($dir -and (Test-Path -LiteralPath (Join-Path $dir "git.exe"))) {
|
||||
$env:Path = "$dir;$env:Path"
|
||||
if (Get-Command git -ErrorAction SilentlyContinue) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw "Git executable not found. Please install Git or add git.exe to PATH."
|
||||
}
|
||||
|
||||
Ensure-GitOnPath
|
||||
|
||||
# Get current timestamp
|
||||
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||
|
||||
@@ -49,4 +78,3 @@ try {
|
||||
Write-Host "Stack trace: $($_.ScriptStackTrace)" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ if (-not $isAdmin) {
|
||||
}
|
||||
|
||||
$taskName = "Git自动提交推送"
|
||||
$scriptPath = "C:\Users\12742\Desktop\douyin_guaji-main\auto_commit_push.ps1"
|
||||
$workingDir = "C:\Users\12742\Desktop\douyin_guaji-main"
|
||||
$scriptPath = Join-Path $PSScriptRoot "auto_commit_push.ps1"
|
||||
$workingDir = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host "Setting up Git Auto Commit Task" -ForegroundColor Cyan
|
||||
@@ -100,4 +100,3 @@ try {
|
||||
}
|
||||
|
||||
pause
|
||||
|
||||
Reference in new issue
Block a user