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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Microsoft.VSCode.DSC initial implementation #57
Microsoft.VSCode.DSC initial implementation #57
Changes from 6 commits
7cfc7d2
3606754
287cae0
d9f2fc9
b649b47
1080e1c
65b9968
7aef889
f21d168
726a981
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few questions about this utility function:
What if
code
is installed, but not in this location?What happens if the command is given invalid flags?
What happens if the command is given valid flags but fails for another reason (e.g. can't connect to the internet)?
What output does this return? Can that output be meaningfully parsed?
Is this utility function intended for use for other resources managing VS Code, or just this one? Can this function shift any of the logic for defining arguments into the function?
If you find it easier to test functions than classes in Pester, you could extract the logic for getting all extensions, installing an extension, and uninstalling an extension into functions that accept the name/version parameters and pass the instance properties or pipe the instance to the function, i.e.:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code can only be installed in two locations based on scope.
C:\Users\<Your Username>\AppData\Local\Programs\Microsoft VS Code
C:\Program Files\Microsoft VS Code
Code.exe doesn't return a proper error message if you provide invalid arguments or even an invalid extension name so it is difficult to produce a reasonable error message from the output. I agree that this is another concern that I have.
The utility functions that we have here are intended to be used for other DSC resources for VSCode. This prototype that I have here is just for adding VSCode extensions, but the code.exe cli tool is very powerful so I'm sure there are more things we can add to this DSC module.
Changed to suggested functions for easier testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are the two locations for VS Code on Windows when installed with WinGet, right? But the logic for installing/updating VS Code extensions is the same when a user installs VS Code in portable mode or on macOS/Linux - I'm not too worried about this, but it's worth keeping in mind that aside from this code snippet, everything else I see in here works fully across platforms and install methodologies, and PSDSC resources published to the gallery, especially for managing something like VS Code, are likely to draw users this code won't support.
I think both deferring this problem and/or just saying "Windows only" support for the module and resources are okay, to be clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good callout. I left a todo comment on the function stating that this is only supported on user/machine installs for 'Windows'. I'll need to figure out a better way to determine the install location especially to support the portable install scenario.