Fix up/down command console output when logger replaces it. #365
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.
Hello, this is tiny PR that fixes pretty unique issue.
I am replacing console with logger function, so that when I run
up
ordown
commands, the console output is logged using logger configuration (I am using log4js).My config looks like:
This all works fine, I am getting STDOUT output similar to:
Log4js
is configured to usestdout
andfile
appenders. The problem is that command output goes to standard output, but does not go to the file for unknown reason. Presumably this is related to the fact that process ends synchronously withconsole.log
call in the code, and internally in node file writing stops too early, just guessing.So, solution is simple. When I defer
process.exit(0);
to the next tick by moving it in separatethen
in the chain, my issue gets resolved. In fact, you are using the same pattern forstatus
command, which I am not interested in logging, but noticed it logs correctly when I remove command condition in the config file.Please consider accepting this PR 😃
Checklist
npm test
passes and has 100% coverage