From 0743a76f5d0aa1d0b349c002dd43b418ac6488d0 Mon Sep 17 00:00:00 2001 From: Ben Miller Date: Thu, 19 Jun 2025 14:09:16 -0600 Subject: [PATCH] foam_sync.ps1 (LIFEBALANCE) 2025-06-19T14:09:16Z --- foam_sync.ps1 | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/foam_sync.ps1 b/foam_sync.ps1 index 9b14a6b..7cf8018 100644 --- a/foam_sync.ps1 +++ b/foam_sync.ps1 @@ -1,19 +1,18 @@ #Requires -Version 5.1 +Set-StrictMode -Version 3.0 -$task = @{ - name = 'FoamGitSync' - description = "Periodically synchronizes the Git repository at $scriptDir using $scriptName." - freqencyMinutes = 2 -} +$scriptPath = $MyInvocation.MyCommand.Path +$scriptDir = Split-Path -Path $scriptPath -Parent +$logDir = Join-Path -Path $scriptDir -ChildPath ".logs" +$logName = "foam_sync.log" +$logFilePath = Join-Path -Path $logDir -ChildPath $logName +$scriptName = (Get-Item $scriptPath).Name -# --- Configuration --- -$frequencyMinutes = $task.freqencyMinutes # How often the Scheduled Task should attempt to run this script -$taskName = $task.name +# --- Task Setup --- +$taskName = 'FoamGitSync' +$taskDescription = "Periodically synchronizes the Git repository at $scriptDir using $scriptName." +$frequencyMinutes = 2 -# --- Log File Setup --- -# Log inside the repository, in a .logs subfolder. Ensure this is in .gitignore -$scriptDirForLog = $PSScriptRoot # Use PSScriptRoot for robustness in determining script's dir -$logDir = Join-Path -Path $scriptDirForLog -ChildPath ".logs" if (-not (Test-Path -Path $logDir)) { New-Item -ItemType Directory -Path $logDir -Force | Out-Null } @@ -22,9 +21,7 @@ $logFilePath = Join-Path -Path $logDir -ChildPath "foam_sync.log" Start-Transcript -Path $logFilePath -Append -IncludeInvocationHeader -Force try { - $scriptPath = $MyInvocation.MyCommand.Path - $scriptDir = Split-Path -Path $scriptPath -Parent - $scriptName = (Get-Item $scriptPath).Name + Write-Host "Script: $scriptName at $scriptPath" Write-Host "Repository directory: $scriptDir"