Merge pull request #340 from SpamixOfficial/main

Add automatic backup of previous configuration
This commit is contained in:
Echo
2025-06-26 11:23:58 -04:00
committed by GitHub
2 changed files with 13 additions and 2 deletions

View File

@@ -1,7 +1,12 @@
try {
# Create config file with API settings
$configPath = "$env:USERPROFILE\.wakatime.cfg"
# If config exists, backup
if (Test-Path $configPath) {
Write-Host "[INFO] Config file already exists, moving into ~/.wakatime.cfg.bak"
Move-Item -Path $configPath -Destination "$configPath.bak"
}
@"
[settings]
api_url = $env:HACKATIME_API_URL

View File

@@ -1,6 +1,12 @@
#!/bin/bash
set -e
# If config exists, backup
if [ -f ~/.wakatime.cfg ]; then
echo "[INFO] Config file already exists, moving into ~/.wakatime.cfg.bak"
mv ~/.wakatime.cfg ~/.wakatime.cfg.bak
fi
# Create or update config file
cat > ~/.wakatime.cfg << EOL
[settings]
@@ -46,4 +52,4 @@ if [ "$http_code" = "200" ] || [ "$http_code" = "202" ]; then
else
echo -e "\nError sending heartbeat: $body"
exit 1
fi
fi