Closed brandon-fryslie closed 9 years ago
I don't have any real comments, no time to read your giss, I'll take your word for it that it was useful.
But I think I'd be remiss if I merged something in with no unit tests. So, make sure current tests pass, and this feature is tested, and I'll merge.
Thank you. I'll submit some tests soon.
I have included 2 tests. One asserts that the callback is run if the output matches the 'wait' string, one asserts that the callback is not called if the output does not match the 'wait' string.
Thank you!
Here is the background of why I made this change and what it enables. I wrote a script to start a series of services that must start serially, some of which take arguments or environment variables from the output of other services. I also wanted to be able to start one, some, or all of the services easily.
I was able to write something like that in about 20 lines using a promise library and 'wait' with a callback to resolve the promise. It turned out to be incredibly powerful. Here is a gist of some of the relevant parts of my script: https://gist.github.com/brandon-fryslie/802e51b1ec385b3eb79c
I think it's a useful feature that enables some really cool ideas. Thoughts?