Adds teams cache remove command. Closes #3205#3224
Adds teams cache remove command. Closes #3205#3224Jwaegebaert wants to merge 16 commits intopnp:mainfrom
teams cache remove command. Closes #3205#3224Conversation
|
Hey @waldekmastykarz, at this point I've worked out some logic for clearing the teams cache for a MacOS and a Windows. For Windows I have been able to do some extensive testing but not yet for the MacOS. Here I have done some research into the logic that would handle this but I'm not 100% sure that this is correct. Could you possibly check this out? |
waldekmastykarz
left a comment
There was a problem hiding this comment.
Great start! Let's do a couple of small adjustments before we continue. I'll also check how it works on mac.
|
Hey @waldekmastykarz, I updated the PR with the adjusments you suggested. For the issue I had with mocking the environment variables within the validate function should be working now. |
|
@Jwaegebaert thank you for your changes following the review from @waldekmastykarz 👏🏻 If you are happy for another review or take place, please mark the PR as |
waldekmastykarz
left a comment
There was a problem hiding this comment.
Let's do a few adjustments. I'll also have a look how we can get it to work on macOS
waldekmastykarz
left a comment
There was a problem hiding this comment.
We're getting there. Let's do a few more adjustments and we'll be able to merge it. Awesome stuff! 👏
| } | ||
| catch { | ||
| if (this.verbose) { | ||
| logger.logToStderr('Teams client isn\'t running'); |
There was a problem hiding this comment.
This message isn't quite right. We can end up here, if there's an issue with closing Teams, which in some cases, like on my work mac, requires running CLI with sudo (I wonder btw. if we could run into the same on Windows where we might need to run the command in an Admin terminal process). Let's make a distinction between Teams not running (which is perfectly fine to proceed) and the command being unable to close Teams (where we need to stop execution) and communicate it to the user.
There was a problem hiding this comment.
Good point! Within the catch I have put an extra check to ensure the teams client isn't running. For all other cases, users will get the error message. I've also applied this to the function removeCacheFiles.
if (errorMessage.includes('ERROR: The process "Teams.exe" not found.')) {
if (this.verbose) {
logger.logToStderr('Teams client isn\'t running');
}
} else {
throw new Error(errorMessage);
}Here you can see that I'm looking specifically at the error message I get when the command on windows can't find teams.exe. With this logic, it would also be interesting to make a comparison with the output a mac would send. What do you think of this approach?
There was a problem hiding this comment.
Let's see if there's a different way about it so that we don't need to rely on string comparison that's different between OSes but also languages. On mac we can see if we found a Teams PID or not, so that's a reliable way to see if Teams is running or not. If we can do the same on Windows, then we'd have a more reliable way of detection.
There was a problem hiding this comment.
Good point, should we maybe take this into a new issue, so we can do a bit more of research on it. Currently I am having trouble fetching the Teams PID and validating the output.
There was a problem hiding this comment.
We can use the current approach for now and meanwhile look at alternatives.
waldekmastykarz
left a comment
There was a problem hiding this comment.
Works like a charm! Let's do one small change to how we return error and update tests so that they correctly verify the command's behavior.
waldekmastykarz
left a comment
There was a problem hiding this comment.
Works nicely! Let's capture ideas for improvement in a separate issue:
- detect Teams PID on Windows to avoid failing if Teams is not running
- detect if the Teams cache folder exists to avoid failing if it doesn't
|
@waldekmastykarz thanks for your help on this one! I will create these issues later today 😄 |
|
Merged manually. Thank you! 👏 |
Thank you for all the hard work and sticking with us 👏 |
Closes #3205