-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
Add --group option #272
Add --group option #272
Conversation
e896d05
to
6aac78b
Compare
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.
Hey! Thanks for this PR, it looks like a really simple approach!
One major thing, though: I think that we should flush buffers as soon as commands close.
./bin/concurrently.js --group "sleep 3; echo hi; sleep 3; echo hey" "echo foo"
[0] hi
[0] hey
[0] sleep 3; echo hi; sleep 3; echo hey exited with code 0
[1] foo
[1] echo foo exited with code 0
In this example, echo foo
finished instantly, however the buffer is not flushed, leading to increased memory usage.
Also, it just feels like a poorer experience that you don't get to know that your command finished early. In the example above, that was only 6 seconds, but it could be much worse, of course.
WDYT?
And can you please remove the TypeScript annotations?
None of the files have this but the ones you touched now :/
src/concurrently.js
Outdated
group: options.group, | ||
commands, | ||
}); | ||
options.logger.observable.subscribe(({command, text}) => outputWriter.write(command, text)); |
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.
For a nicer API... what do you think if Logger
had a subscribe
method?
options.logger.observable.subscribe(({command, text}) => outputWriter.write(command, text)); | |
options.logger.subscribe(({command, text}) => outputWriter.write(command, text)); |
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.
I initially had this actually! I ended up removing it because then it made look logger
look like an Observable
, which I thought might be confusing (cause then folks might expect it to have other Observable
methods/props). Then I thought maybe I should make Logger extends Observable
, and then I decided I'd just KISS and use composition :P
@cdrini I really like your |
Goodness has it really been four months 😅 Sorry for the delay folks! Taking a look at this today 👍 Thanks for the review @gustavohenke ! And thanks for the +1 @Snaptags :) |
6aac78b
to
2130c88
Compare
Ok! Rebased off latest master, and confirmed working 👍
|
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.
So for me, I specifically want the output to appear as if they ran in sequence, even if one finishes earlier than the others.
We can tackle that independently, e.g. #257 asks for the sequential running.
One of the hardest parts for me jumping into this code was trying to figure out what exactly a Command was, since a few different things are referred to by that name. Would love to save the next person some time.
Understandable!
I love TS, but the annotations are not fit for the codebase yet.
Some of the dependencies have started using ES Modules, and I'd hate to force concurrently users into ESM.
So one of the alternatives I've been thinking is to use Typescript. Maybe that would provide an even better developer experience for folks using the programmatic API.
This option makes it so that the output is displayed as if the commands were run sequentially.
2130c88
to
4122944
Compare
4122944
to
8346fc5
Compare
No worries, I removed the type hints :) I find the comment typehints to be a really great way to get 95% of the benefits of type annotations, without having to require users to do anything special. With comments, you don't have to switch the entire codebase to ESM or TS, but you do get that sweet sweet auto-complete in vs code, which is why I love it! :) Eg Oh, #257 is different; that is about actually running the commands in sequence. I believe the main purpose of the EDIT: I think this is what other folks are asking for as well: #75 (comment) . Flushing output on exit would cause the output to be garbled/inter-mixed. |
@gustavohenke Anything I can do to help move this along? I'd love to be able to start using this :) |
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.
redacted
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.
Overall idea and implementation here LGTM!
I've started porting the codebase to TypeScript, so this has obviously caused a bunch of conflicts 😅
But since it was me who held this PR open for so long, I'll fix those.
Furthermore, I'm thinking about a different name for the feature, and maybe refactoring some bits, so I'll push that to your branch as well.
d3ac429
to
3528873
Compare
Happy new year! This is now out in |
Well isn't that the sweetest New Year's present! Awesome! Thank you so much! And absolutely no worries ; I know you're busy, and I know I haven't exactly been super on top of it either 😅 Hope the TS migration wasn't too difficult! Happy New Year! 🥂 |
Closes #75. This option makes it so that the output is displayed as if the commands were run sequentially.
The current approach adds an intercepting layer between
Logger
and the actual output stream calledOutputWriter
, which buffers each command's output as necessary. This worked nicely, because it was completely orthogonal to any of the other code, but did result in a few breaking changes to the APIs:Logger
no longer takes in anoutputStream
; it has anobservable
which it emits to. This makesLogger
essentially a logger formatting class.Logger#log
and friends now pass along the command value, so thatOutputWriter
can use it for buffering.concurrently
now takes inlogger
andoutputStream
and wires them together using the newOutputWriter
class.Examples: