♻️ refactor(vscode): improve Export-VSCodeProfiles robustness and add Pester tests - #32
Open
chriskyfung wants to merge 4 commits into
Open
♻️ refactor(vscode): improve Export-VSCodeProfiles robustness and add Pester tests#32chriskyfung wants to merge 4 commits into
chriskyfung wants to merge 4 commits into
Conversation
- Convert script to functional structure - Add comprehensive error handling and validation - Implement -WhatIf support for dry runs - Improve logging with helper functions - Standardize path handling using Join-Path
- Convert function-based flow to begin/process/end - Implement native ShouldProcess for WhatIf support - Add parameter validation for output and data paths - Streamline profile discovery and extension export - Improve error handling and logging consistency
- Replace script-scoped variables with locals - Add explicit PowerShell version requirements - Improve profile discovery and error handling - Move validation logic into the process block - Standardize error reporting and flow control
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR refactors
Export-VSCodeProfiles.ps1to be more robust, configurable, and testable, and adds a Pester test suite covering the new behavior.Changes
VSCode/Export-VSCodeProfiles.ps1-OutputDirectoryand-VSCodeUserDataPathallow customizing the export destination and VS Code user data location-WhatIfsupport — every operation is wrapped in$PSCmdlet.ShouldProcess()viaSupportsShouldProcessstorage.json, or thecodeCLI is missingSet-StrictMode,$ErrorActionPreference = 'Stop',$LASTEXITCODEchecks, per-profile error handling that warns and skips instead of aborting the whole export, andJoin-Path/Get-Content -RawthroughoutTests/VSCode/Export-VSCodeProfiles.Tests.ps1(new)-WhatIfbehaviorGet-Commandmocks so tests never touch real VS Code dataTesting