-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSync-Settings.ps1
More file actions
26 lines (22 loc) · 1.1 KB
/
Copy pathSync-Settings.ps1
File metadata and controls
26 lines (22 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$settingspath = "$env:LOCALAPPDATA\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json"
$settingsprops = Get-ChildItem $settingspath | Sort {$_.LastWriteTime} | select -last 1
$settingslastmodified = [DateTime]$settingsprops.LastWriteTime
If (-not (Test-Path "last-synced")) {
New-Item -ItemType File "last-synced"
$settingslastmodified >> last-synced
}
$lastsyncedtext = cat last-synced | Out-String
$lastsynced = [DateTime]$lastsyncedtext
if ($settingslastmodified -gt $lastsynced) {
Write-Host "Detected changes to winget settings.json. Copying to dotfiles and pushing to github repo..." -ForegroundColor Red
Remove-Item "settings.json.bak"
Rename-Item "settings.json" "settings.json.bak" -Force
Copy-Item $settingspath "settings.json"
Remove-Item last-synced
Get-Date >> last-synced
git add ../winget/*
git commit -m "Updated winget settings"
git push
}
# Copy-Item "settings.json" "$env:LOCALAPPDATA\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState"
# Write-Host "✔️ Successfully copied file settings.json to local app data folder." -ForegroundColor Green