Node version (or tell us if you're using electron or some other framework):
v8.11.3
ShellJS version (the most recent version/Github branch you see the bug on):
0.8.2
Operating system:
Mac OS X
Description of the bug:
There doesn't seem to be a way to suppress stdout from echo() even when redirecting to another command / pipe.
Based on the code, it seems like no matter what, the call to sys.stdout.write() will happen.
|
process.stdout.write(output); |
|
|
|
return output; |
Example ShellJS command to reproduce the error:
(given a file testfile without the string asdfasdf at the beginning of a line):
const shell = require('shelljs');
if (!shell.grep(/^asdfasdf/, 'testfile').stdout.trim()) {
shell.echo({silent: true}, 'asdfasdf').toEnd('testfile');
}
In this case, whether {silent: true} (which it seems like it's supposed to be parsed, tho not do anything, based on
) is there or not, the output is echoed
and appended to
testfile. Also, in this case,
{silent: true} gets added to the file as well.
const shell = require('shelljs');
if (!shell.grep(/^asdfasdf/, 'testfile').stdout.trim()) {
shell.config.silent = true;
shell.echo('asdfasdf').toEnd('testfile');
}
The above code also doesn't suppress stdout.
Node version (or tell us if you're using electron or some other framework):
v8.11.3
ShellJS version (the most recent version/Github branch you see the bug on):
0.8.2
Operating system:
Mac OS X
Description of the bug:
There doesn't seem to be a way to suppress stdout from
echo()even when redirecting to another command / pipe.Based on the code, it seems like no matter what, the call to
sys.stdout.write()will happen.shelljs/src/echo.js
Lines 58 to 60 in 4bd22e7
Example ShellJS command to reproduce the error:
(given a file
testfilewithout the string asdfasdf at the beginning of a line):In this case, whether
{silent: true}(which it seems like it's supposed to be parsed, tho not do anything, based onshelljs/src/echo.js
Lines 38 to 40 in 4bd22e7
testfile. Also, in this case,{silent: true}gets added to the file as well.The above code also doesn't suppress stdout.