Skip to content
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

chocolatey-misc-helpers: Start-WaitAndStop remake #364

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

virginviolet
Copy link

@virginviolet virginviolet commented Oct 23, 2024

I had the issue of Start-WaitAndStop only working if the process appeared within 10 seconds (the timer set in Start-WaitAndStop.ps1). So I remade the functions my way.

It bothered me also that, even when you got the function working as intended, the ** Stopping $ProcessName process... message would not appear, as it's executed in an isolated environment (as I understand it). Granted, I haven't tried it in an actual Chocolatey install, so maybe I could be wrong.
To address this, I added a Warning message in Start-WaitAndStop.ps1 that says Waiting to stop '$ProcessName'....
I also created a new function, Receive-WaitAndStop that grabs the output from Start-WaitAndStopActual. I don't know when this would ever be useful, but here is how you could use it.

Start-WaitAndStop $process
Receive-WaitAndStop
Install-ChocolateyInstallPackage @packageArgs
Receive-WaitAndStop -Wait -WriteEvents

Other changes:

  • Parameter for how long to wait at maximum. Example: Start-WaitAndStop -Seconds 600 (Default is 300).
  • Parameter for looking interval. So if you wanted it to check for the process every 2 seconds, you would use -Interval 2 (default is now 3).
  • Bonus messages to the Debug stream.
  • Doesn't pause the install script for 10 seconds.
  • Letter case fixes/improvements (function and parameter names are case-insensitive, so this is just pedantry, but it won't break anything).

@virginviolet virginviolet changed the title chocolatey-misc-helpers: Reworking Start-WaitAndStop chocolatey-misc-helpers: Start-WaitAndStop remake Oct 24, 2024
@bcurran3
Copy link
Owner

Hi @virginviolet.

First thanks for finding this and wanting to make it better.

I put a few comments in on two of the files. I only put a few minutes into looking at this but will look at it deeper in the future and after you've seen my comments.

@virginviolet
Copy link
Author

Thanks.
How do I view your comments?

@virginviolet
Copy link
Author

virginviolet commented Nov 5, 2024

For the record, I just discovered that core-extentions has a helper that addresses the same issue as Start-WaitAndStop. Remove-Process, that is.
It doesn't allow install/uninstall scripts to continue though, but rather halts the entire execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants