From 65226f3984480d0bc7932fd8d76a328f08308850 Mon Sep 17 00:00:00 2001 From: undergroundwires Date: Sat, 27 Feb 2021 14:39:29 +0100 Subject: [PATCH] add better error messages to setting vscode settings --- src/application/collections/windows.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/application/collections/windows.yaml b/src/application/collections/windows.yaml index cf61e1db..df70c1c3 100644 --- a/src/application/collections/windows.yaml +++ b/src/application/collections/windows.yaml @@ -4394,11 +4394,18 @@ functions: parameters: code: $jsonfile = \"$env:APPDATA\Code\User\settings.json\"; + if (!(Test-Path $jsonfile -PathType Leaf)) { + Write-Host \"No updates. Settings file was not at $jsonfile\"; + exit 0; + } $json = Get-Content $jsonfile | Out-String | ConvertFrom-Json; $json | Add-Member -Type NoteProperty -Name '{{ $setting }}' -Value {{ $powerShellValue }} -Force; $json | ConvertTo-Json | Set-Content $jsonfile; revertCode: $jsonfile = \"$env:APPDATA\Code\User\settings.json\"; + if (!(Test-Path $jsonfile -PathType Leaf)) { + Write-Error \"Settings file could not be found at $jsonfile\" -ErrorAction Stop; + } $json = Get-Content $jsonfile | ConvertFrom-Json; $json.PSObject.Properties.Remove('{{ $setting }}'); $json | ConvertTo-Json | Set-Content $jsonfile;