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.
Hi rse!
I've made some changes to the code in order to facilitate progress tracking and better logging as the job progresses.
I've changed the .execute code to perform
spawn
instead ofexecFile
, which allows us to handle stdout and stderr as they arrive. These can now be caputred line by line by chaning the Prince call with:Registering multiple event handlers on the same events is possible too.
Price supports the option
--structured-log=progress
which can be used to track progress of the job.This can now be achieved like this:
The trackProgress function may look something like this:
Not sure if this is an ideal implementation though. First of, Prince doesn't seem to output anything to stdout, but I implemented a stdout-handler as well, as I'm not sure if other versions of prince may output something to stdout.
Also, it is maybe a little strange with .on handlers when things like error is handled as a promise rejection (kind of a mix of two different patterns). In this regard the chaining function name could be called .onOutput instead. However I find the .on pattern to be familiar and flexible for possible future expansions.
What do you think?