fix: silent does not always work (fixes #851)#861
fix: silent does not always work (fixes #851)#861uttpal wants to merge 1 commit intoshelljs:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #861 +/- ##
======================================
Coverage 95.8% 95.8%
======================================
Files 34 34
Lines 1262 1262
======================================
Hits 1209 1209
Misses 53 53
Continue to review full report at Codecov.
|
nfischer
left a comment
There was a problem hiding this comment.
Thanks for this quick fix! Left a couple comments, otherwise this is a great help.
|
|
||
| if (code !== 0) { | ||
| common.error(stderr, code, { continue: true }); | ||
| common.error(stderr, code, { continue: true, silent: opts.silent }); |
There was a problem hiding this comment.
Actually, I believe correct behavior (comparing against v0.7.8) is to never print this. So, this should be silent: true.
There was a problem hiding this comment.
just to clarify, here silent: true will always be there?
There was a problem hiding this comment.
In my previous comment, I intended for you to change this line to:
common.error(stderr, code, { continue: true, silent: true });| t.is(result.stderr, '1234\n'); | ||
| }); | ||
|
|
||
| test('check if stdout + stderr should not be printed to console if silent', t => { |
There was a problem hiding this comment.
This test is great. Can you also add a second test to handle the case for silent: false?
Optional suggestion: you can replace the command with shell.exec('shx ls resources/file1.txt filethatdoesnotexist'). shx ls is cross-platform, guaranteed to produce both stdout & stderr, and guaranteed to have a non-zero exit code.
There was a problem hiding this comment.
Above you suggested that silent will always be true, then there will be no silent: falsecase?
There was a problem hiding this comment.
Above you suggested that silent will always be true
For this PR, correct behavior is to always pass { silent: true } to common.error(), regardless of config.silent or exec's { silent: true } option.
then there will be no
silent: falsecase?
I think two cases are interesting:
- when the user passes
silent: true, there should be no stdio - when the user passes
silent: false(or, equivalently, the default), the command's stdio should go to stdio, but exec should not also printexec: <something here>to stderr
Does this make sense?
There was a problem hiding this comment.
I will fix and add test asap
| shell.config.silent = true; | ||
|
|
||
| test.beforeEach(() => { | ||
| mocks.init(); |
|
Any update on this? The current work around is to globally silent the module using |
|
I believe I still need a change from @uttpal (if that's not the case, please let me know I should re-review this). |
|
FYI I cherry-picked this to #892 |
|
Close in favor of #892 |
No description provided.